Skip to content

Commit b405aa2

Browse files
authored
Rollup merge of #62806 - mati865:clippy, r=TimNN
Fix few Clippy warnings
2 parents 2826bdc + 124f6ef commit b405aa2

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

Diff for: src/liballoc/collections/btree/map.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<K: Clone, V: Clone> Clone for BTreeMap<K, V> {
200200
}
201201
}
202202

203-
if self.len() == 0 {
203+
if self.is_empty() {
204204
// Ideally we'd call `BTreeMap::new` here, but that has the `K:
205205
// Ord` constraint, which this method lacks.
206206
BTreeMap {
@@ -759,12 +759,12 @@ impl<K: Ord, V> BTreeMap<K, V> {
759759
#[stable(feature = "btree_append", since = "1.11.0")]
760760
pub fn append(&mut self, other: &mut Self) {
761761
// Do we have to append anything at all?
762-
if other.len() == 0 {
762+
if other.is_empty() {
763763
return;
764764
}
765765

766766
// We can just swap `self` and `other` if `self` is empty.
767-
if self.len() == 0 {
767+
if self.is_empty() {
768768
mem::swap(self, other);
769769
return;
770770
}

Diff for: src/liballoc/collections/linked_list.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,15 @@ impl<T> LinkedList<T> {
237237

238238
// Not creating new mutable (unique!) references overlapping `element`.
239239
match node.prev {
240-
Some(prev) => (*prev.as_ptr()).next = node.next.clone(),
240+
Some(prev) => (*prev.as_ptr()).next = node.next,
241241
// this node is the head node
242-
None => self.head = node.next.clone(),
242+
None => self.head = node.next,
243243
};
244244

245245
match node.next {
246-
Some(next) => (*next.as_ptr()).prev = node.prev.clone(),
246+
Some(next) => (*next.as_ptr()).prev = node.prev,
247247
// this node is the tail node
248-
None => self.tail = node.prev.clone(),
248+
None => self.tail = node.prev,
249249
};
250250

251251
self.len -= 1;

Diff for: src/liballoc/rc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ impl<T> Rc<[T]> {
815815
let slice = from_raw_parts_mut(self.elems, self.n_elems);
816816
ptr::drop_in_place(slice);
817817

818-
Global.dealloc(self.mem, self.layout.clone());
818+
Global.dealloc(self.mem, self.layout);
819819
}
820820
}
821821
}

Diff for: src/liballoc/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ impl<T> Arc<[T]> {
703703
let slice = from_raw_parts_mut(self.elems, self.n_elems);
704704
ptr::drop_in_place(slice);
705705

706-
Global.dealloc(self.mem.cast(), self.layout.clone());
706+
Global.dealloc(self.mem.cast(), self.layout);
707707
}
708708
}
709709
}

Diff for: src/libcore/alloc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,11 @@ pub unsafe trait Alloc {
827827
let old_size = layout.size();
828828

829829
if new_size >= old_size {
830-
if let Ok(()) = self.grow_in_place(ptr, layout.clone(), new_size) {
830+
if let Ok(()) = self.grow_in_place(ptr, layout, new_size) {
831831
return Ok(ptr);
832832
}
833833
} else if new_size < old_size {
834-
if let Ok(()) = self.shrink_in_place(ptr, layout.clone(), new_size) {
834+
if let Ok(()) = self.shrink_in_place(ptr, layout, new_size) {
835835
return Ok(ptr);
836836
}
837837
}

Diff for: src/libcore/str/lossy.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl<'a> Iterator for Utf8LossyChunksIter<'a> {
4646
type Item = Utf8LossyChunk<'a>;
4747

4848
fn next(&mut self) -> Option<Utf8LossyChunk<'a>> {
49-
if self.source.len() == 0 {
49+
if self.source.is_empty() {
5050
return None;
5151
}
5252

@@ -141,7 +141,7 @@ impl fmt::Display for Utf8Lossy {
141141
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142142
// If we're the empty string then our iterator won't actually yield
143143
// anything, so perform the formatting manually
144-
if self.bytes.len() == 0 {
144+
if self.bytes.is_empty() {
145145
return "".fmt(f)
146146
}
147147

Diff for: src/libstd/io/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
19231923
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
19241924
if !self.done_first {
19251925
match self.first.read(buf)? {
1926-
0 if buf.len() != 0 => self.done_first = true,
1926+
0 if !buf.is_empty() => self.done_first = true,
19271927
n => return Ok(n),
19281928
}
19291929
}
@@ -1955,7 +1955,7 @@ impl<T: BufRead, U: BufRead> BufRead for Chain<T, U> {
19551955
fn fill_buf(&mut self) -> Result<&[u8]> {
19561956
if !self.done_first {
19571957
match self.first.fill_buf()? {
1958-
buf if buf.len() == 0 => { self.done_first = true; }
1958+
buf if buf.is_empty() => { self.done_first = true; }
19591959
buf => return Ok(buf),
19601960
}
19611961
}

Diff for: src/libstd/sys/unix/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ unsafe impl GlobalAlloc for System {
2929
if layout.align() <= MIN_ALIGN && layout.align() <= layout.size() {
3030
libc::calloc(layout.size(), 1) as *mut u8
3131
} else {
32-
let ptr = self.alloc(layout.clone());
32+
let ptr = self.alloc(layout);
3333
if !ptr.is_null() {
3434
ptr::write_bytes(ptr, 0, layout.size());
3535
}

Diff for: src/libstd/sys/unix/process/process_unix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ impl Command {
277277
if self.get_gid().is_some() ||
278278
self.get_uid().is_some() ||
279279
self.env_saw_path() ||
280-
self.get_closures().len() != 0 {
280+
!self.get_closures().is_empty() {
281281
return Ok(None)
282282
}
283283

0 commit comments

Comments
 (0)