Clippy lints

This commit is contained in:
nora 2022-10-02 12:06:17 +02:00
parent b5f6318fce
commit d4ac7596da
No known key found for this signature in database
5 changed files with 23 additions and 16 deletions

View file

@ -29,15 +29,15 @@ impl<W: Write, O: FmtOpts> Formatter<W, O> {
self.buf.write_str(str) self.buf.write_str(str)
} }
pub fn debug_list<'b>(&'b mut self) -> DebugList<'b, W, O> { pub fn debug_list(&mut self) -> DebugList<'_, W, O> {
debug_list_new(self) debug_list_new(self)
} }
pub fn debug_set<'b>(&'b mut self) -> DebugSet<'b, W, O> { pub fn debug_set(&mut self) -> DebugSet<'_, W, O> {
debug_set_new(self) debug_set_new(self)
} }
pub fn debug_map<'b>(&'b mut self) -> DebugMap<'b, W, O> { pub fn debug_map(&mut self) -> DebugMap<'_, W, O> {
debug_map_new(self) debug_map_new(self)
} }
@ -311,9 +311,9 @@ pub struct DebugSet<'a, W, O> {
inner: DebugInner<'a, W, O>, inner: DebugInner<'a, W, O>,
} }
pub(super) fn debug_set_new<'a, W: Write, O: FmtOpts>( pub(super) fn debug_set_new<W: Write, O: FmtOpts>(
fmt: &'a mut fmt::Formatter<W, O>, fmt: &mut fmt::Formatter<W, O>,
) -> DebugSet<'a, W, O> { ) -> DebugSet<'_, W, O> {
let result = fmt.write_str("{"); let result = fmt.write_str("{");
DebugSet { DebugSet {
inner: DebugInner { inner: DebugInner {
@ -354,9 +354,9 @@ pub struct DebugList<'a, W, O> {
inner: DebugInner<'a, W, O>, inner: DebugInner<'a, W, O>,
} }
pub(super) fn debug_list_new<'a, W: Write, O: FmtOpts>( pub(super) fn debug_list_new<W: Write, O: FmtOpts>(
fmt: &'a mut fmt::Formatter<W, O>, fmt: &mut fmt::Formatter<W, O>,
) -> DebugList<'a, W, O> { ) -> DebugList<'_, W, O> {
let result = fmt.write_str("["); let result = fmt.write_str("[");
DebugList { DebugList {
inner: DebugInner { inner: DebugInner {
@ -402,9 +402,9 @@ pub struct DebugMap<'a, W, O> {
state: PadAdapterState, state: PadAdapterState,
} }
pub(super) fn debug_map_new<'a, 'b, W: Write, O: FmtOpts>( pub(super) fn debug_map_new<W: Write, O: FmtOpts>(
fmt: &'a mut fmt::Formatter<W, O>, fmt: &mut fmt::Formatter<W, O>,
) -> DebugMap<'a, W, O> { ) -> DebugMap<'_, W, O> {
let result = fmt.write_str("{"); let result = fmt.write_str("{");
DebugMap { DebugMap {
fmt, fmt,

View file

@ -8,7 +8,7 @@ mod impl_prelude {
impl<T: Debug, const N: usize> Debug for [T; N] { impl<T: Debug, const N: usize> Debug for [T; N] {
fn fmt<W: Write, O: FmtOpts>(&self, f: &mut Formatter<W, O>) -> Result { fn fmt<W: Write, O: FmtOpts>(&self, f: &mut Formatter<W, O>) -> Result {
<[T] as Debug>::fmt(&&self[..], f) <[T] as Debug>::fmt(&self[..], f)
} }
} }

View file

@ -333,10 +333,10 @@ impl<W: Write, O: FmtOpts> Formatter<W, O> {
// here. // here.
s.get(..i).unwrap_or(s) s.get(..i).unwrap_or(s)
} else { } else {
&s s
} }
} else { } else {
&s s
}; };
// The `width` field is more of a `min-width` parameter at this point. // The `width` field is more of a `min-width` parameter at this point.
match self.width() { match self.width() {

View file

@ -23,7 +23,7 @@ impl Write for &'_ mut [u8] {
return Err(Error); return Err(Error);
} }
let (a, b) = core::mem::replace(self, &mut []).split_at_mut(data.len()); let (a, b) = core::mem::take(self).split_at_mut(data.len());
a.copy_from_slice(data); a.copy_from_slice(data);
*self = b; *self = b;
Ok(()) Ok(())

View file

@ -29,3 +29,10 @@ fn only_eval_once() {
}); });
assert_eq!(evil.get(), 1); assert_eq!(evil.get(), 1);
} }
#[test]
fn dont_move() {
let string = "uwu".to_string();
let _ = format!("{string}");
assert_eq!("uwu", string);
}