From f93032c818da6482777e6fa35a535a494241a0f1 Mon Sep 17 00:00:00 2001 From: Mateusz Mikuła Date: Thu, 18 Jul 2019 14:16:04 +0200 Subject: Fix clippy::clone_on_copy warnings --- src/libcore/alloc.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libcore') diff --git a/src/libcore/alloc.rs b/src/libcore/alloc.rs index 487f3b76fc7..5d0333d5226 100644 --- a/src/libcore/alloc.rs +++ b/src/libcore/alloc.rs @@ -827,11 +827,11 @@ pub unsafe trait Alloc { let old_size = layout.size(); if new_size >= old_size { - if let Ok(()) = self.grow_in_place(ptr, layout.clone(), new_size) { + if let Ok(()) = self.grow_in_place(ptr, layout, new_size) { return Ok(ptr); } } else if new_size < old_size { - if let Ok(()) = self.shrink_in_place(ptr, layout.clone(), new_size) { + if let Ok(()) = self.shrink_in_place(ptr, layout, new_size) { return Ok(ptr); } } -- cgit 1.4.1-3-g733a5 From 124f6ef7cdea1083b0cbe0371e3f7fbe1152a9d1 Mon Sep 17 00:00:00 2001 From: Mateusz Mikuła Date: Thu, 18 Jul 2019 14:22:22 +0200 Subject: Fix clippy::len_zero warnings --- src/liballoc/collections/btree/map.rs | 6 +++--- src/libcore/str/lossy.rs | 4 ++-- src/libstd/io/mod.rs | 4 ++-- src/libstd/sys/unix/process/process_unix.rs | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libcore') diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index d466948a017..8bd1a3f44a3 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -200,7 +200,7 @@ impl Clone for BTreeMap { } } - if self.len() == 0 { + if self.is_empty() { // Ideally we'd call `BTreeMap::new` here, but that has the `K: // Ord` constraint, which this method lacks. BTreeMap { @@ -759,12 +759,12 @@ impl BTreeMap { #[stable(feature = "btree_append", since = "1.11.0")] pub fn append(&mut self, other: &mut Self) { // Do we have to append anything at all? - if other.len() == 0 { + if other.is_empty() { return; } // We can just swap `self` and `other` if `self` is empty. - if self.len() == 0 { + if self.is_empty() { mem::swap(self, other); return; } diff --git a/src/libcore/str/lossy.rs b/src/libcore/str/lossy.rs index b291579553a..e8f747f1a67 100644 --- a/src/libcore/str/lossy.rs +++ b/src/libcore/str/lossy.rs @@ -46,7 +46,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> { type Item = Utf8LossyChunk<'a>; fn next(&mut self) -> Option> { - if self.source.len() == 0 { + if self.source.is_empty() { return None; } @@ -141,7 +141,7 @@ impl fmt::Display for Utf8Lossy { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // If we're the empty string then our iterator won't actually yield // anything, so perform the formatting manually - if self.bytes.len() == 0 { + if self.bytes.is_empty() { return "".fmt(f) } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index a8d4d1181aa..3fbe9f3125f 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1923,7 +1923,7 @@ impl Read for Chain { fn read(&mut self, buf: &mut [u8]) -> Result { if !self.done_first { match self.first.read(buf)? { - 0 if buf.len() != 0 => self.done_first = true, + 0 if !buf.is_empty() => self.done_first = true, n => return Ok(n), } } @@ -1955,7 +1955,7 @@ impl BufRead for Chain { fn fill_buf(&mut self) -> Result<&[u8]> { if !self.done_first { match self.first.fill_buf()? { - buf if buf.len() == 0 => { self.done_first = true; } + buf if buf.is_empty() => { self.done_first = true; } buf => return Ok(buf), } } diff --git a/src/libstd/sys/unix/process/process_unix.rs b/src/libstd/sys/unix/process/process_unix.rs index be38a1334ec..fc1e33137c8 100644 --- a/src/libstd/sys/unix/process/process_unix.rs +++ b/src/libstd/sys/unix/process/process_unix.rs @@ -277,7 +277,7 @@ impl Command { if self.get_gid().is_some() || self.get_uid().is_some() || self.env_saw_path() || - self.get_closures().len() != 0 { + !self.get_closures().is_empty() { return Ok(None) } -- cgit 1.4.1-3-g733a5