diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-07-28 11:11:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-07-28 11:11:08 +0200 |
| commit | b405aa2d0301c5fc448299501278ae2db4e15e50 (patch) | |
| tree | 25f749e1f7d4c446983d7e3dd9b16eb0bf4b8dab /src | |
| parent | 2826bdcfa6fecc656294534162fb5990d3d53cf5 (diff) | |
| parent | 124f6ef7cdea1083b0cbe0371e3f7fbe1152a9d1 (diff) | |
| download | rust-b405aa2d0301c5fc448299501278ae2db4e15e50.tar.gz rust-b405aa2d0301c5fc448299501278ae2db4e15e50.zip | |
Rollup merge of #62806 - mati865:clippy, r=TimNN
Fix few Clippy warnings
Diffstat (limited to 'src')
| -rw-r--r-- | src/liballoc/collections/btree/map.rs | 6 | ||||
| -rw-r--r-- | src/liballoc/collections/linked_list.rs | 8 | ||||
| -rw-r--r-- | src/liballoc/rc.rs | 2 | ||||
| -rw-r--r-- | src/liballoc/sync.rs | 2 | ||||
| -rw-r--r-- | src/libcore/alloc.rs | 4 | ||||
| -rw-r--r-- | src/libcore/str/lossy.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/unix/alloc.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/process/process_unix.rs | 2 |
9 files changed, 17 insertions, 17 deletions
diff --git a/src/liballoc/collections/btree/map.rs b/src/liballoc/collections/btree/map.rs index 7cf779b3e72..1683b810556 100644 --- a/src/liballoc/collections/btree/map.rs +++ b/src/liballoc/collections/btree/map.rs @@ -200,7 +200,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> { } } - 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<K: Ord, V> BTreeMap<K, V> { #[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/liballoc/collections/linked_list.rs b/src/liballoc/collections/linked_list.rs index db0d6e2f9b9..bbb96725ea0 100644 --- a/src/liballoc/collections/linked_list.rs +++ b/src/liballoc/collections/linked_list.rs @@ -237,15 +237,15 @@ impl<T> LinkedList<T> { // Not creating new mutable (unique!) references overlapping `element`. match node.prev { - Some(prev) => (*prev.as_ptr()).next = node.next.clone(), + Some(prev) => (*prev.as_ptr()).next = node.next, // this node is the head node - None => self.head = node.next.clone(), + None => self.head = node.next, }; match node.next { - Some(next) => (*next.as_ptr()).prev = node.prev.clone(), + Some(next) => (*next.as_ptr()).prev = node.prev, // this node is the tail node - None => self.tail = node.prev.clone(), + None => self.tail = node.prev, }; self.len -= 1; diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 36d54656795..0d0ff7c16f1 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -815,7 +815,7 @@ impl<T> Rc<[T]> { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); - Global.dealloc(self.mem, self.layout.clone()); + Global.dealloc(self.mem, self.layout); } } } diff --git a/src/liballoc/sync.rs b/src/liballoc/sync.rs index 7cb826ee024..93aff733724 100644 --- a/src/liballoc/sync.rs +++ b/src/liballoc/sync.rs @@ -703,7 +703,7 @@ impl<T> Arc<[T]> { let slice = from_raw_parts_mut(self.elems, self.n_elems); ptr::drop_in_place(slice); - Global.dealloc(self.mem.cast(), self.layout.clone()); + Global.dealloc(self.mem.cast(), self.layout); } } } 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); } } 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<Utf8LossyChunk<'a>> { - 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 e951b575773..09b6b694f7b 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -1923,7 +1923,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> { fn read(&mut self, buf: &mut [u8]) -> Result<usize> { 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<T: BufRead, U: BufRead> BufRead for Chain<T, U> { 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/alloc.rs b/src/libstd/sys/unix/alloc.rs index 2c2dd3b77ea..f47dc92d2de 100644 --- a/src/libstd/sys/unix/alloc.rs +++ b/src/libstd/sys/unix/alloc.rs @@ -29,7 +29,7 @@ unsafe impl GlobalAlloc for System { if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() { libc::calloc(layout.size(), 1) as *mut u8 } else { - let ptr = self.alloc(layout.clone()); + let ptr = self.alloc(layout); if !ptr.is_null() { ptr::write_bytes(ptr, 0, layout.size()); } 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) } |
