Skip to content

Commit 3b3f7bd

Browse files
authored
Rollup merge of #71562 - matthiaskrgr:cl7ppy, r=Dylan-DPC
fix more clippy warnings clippy::{redundant_pattern_matching, clone_on_copy, iter_cloned_collect, option_as_ref_deref, match_ref_pats} r? @Dylan-DPC
2 parents 96c1bb5 + 8862f82 commit 3b3f7bd

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

src/liballoc/collections/binary_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ impl<'a, T: Ord> Drop for DrainSorted<'a, T> {
12691269

12701270
impl<'r, 'a, T: Ord> Drop for DropGuard<'r, 'a, T> {
12711271
fn drop(&mut self) {
1272-
while let Some(_) = self.0.inner.pop() {}
1272+
while self.0.inner.pop().is_some() {}
12731273
}
12741274
}
12751275

src/liballoc/collections/linked_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
972972
fn drop(&mut self) {
973973
// Continue the same loop we do below. This only runs when a destructor has
974974
// panicked. If another one panics this will abort.
975-
while let Some(_) = self.0.pop_front_node() {}
975+
while self.0.pop_front_node().is_some() {}
976976
}
977977
}
978978

src/librustc_driver/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -618,15 +618,15 @@ impl RustcDefaultCalls {
618618
) -> Compilation {
619619
let r = matches.opt_strs("Z");
620620
if r.iter().any(|s| *s == "ls") {
621-
match input {
622-
&Input::File(ref ifile) => {
621+
match *input {
622+
Input::File(ref ifile) => {
623623
let path = &(*ifile);
624624
let mut v = Vec::new();
625625
locator::list_file_metadata(&sess.target.target, path, metadata_loader, &mut v)
626626
.unwrap();
627627
println!("{}", String::from_utf8(v).unwrap());
628628
}
629-
&Input::Str { .. } => {
629+
Input::Str { .. } => {
630630
early_error(ErrorOutputType::default(), "cannot list metadata for stdin");
631631
}
632632
}

src/librustc_interface/util.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,8 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
625625
| ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. })
626626
| ast::TyKind::Paren(ref subty) => involves_impl_trait(subty),
627627
ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()),
628-
ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| {
629-
match seg.args.as_ref().map(|generic_arg| &**generic_arg) {
628+
ast::TyKind::Path(_, ref path) => {
629+
path.segments.iter().any(|seg| match seg.args.as_deref() {
630630
None => false,
631631
Some(&ast::GenericArgs::AngleBracketed(ref data)) => {
632632
data.args.iter().any(|arg| match arg {
@@ -647,8 +647,8 @@ impl<'a, 'b> ReplaceBodyWithLoop<'a, 'b> {
647647
any_involves_impl_trait(data.inputs.iter())
648648
|| ReplaceBodyWithLoop::should_ignore_fn(&data.output)
649649
}
650-
}
651-
}),
650+
})
651+
}
652652
_ => false,
653653
}
654654
}

src/librustc_metadata/rmeta/decoder/cstore_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl CStore {
431431
ident,
432432
id: ast::DUMMY_NODE_ID,
433433
span,
434-
attrs: attrs.iter().cloned().collect(),
434+
attrs: attrs.to_vec(),
435435
kind: ast::ItemKind::MacroDef(data.get_macro(id.index, sess)),
436436
vis: source_map::respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
437437
tokens: None,

src/librustc_mir/transform/copy_prop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl<'tcx> Action<'tcx> {
246246
}
247247

248248
fn constant(src_constant: &Constant<'tcx>) -> Option<Action<'tcx>> {
249-
Some(Action::PropagateConstant((*src_constant).clone()))
249+
Some(Action::PropagateConstant(*src_constant))
250250
}
251251

252252
fn perform(
@@ -371,7 +371,7 @@ impl<'tcx> MutVisitor<'tcx> for ConstantPropagationVisitor<'tcx> {
371371
_ => return,
372372
}
373373

374-
*operand = Operand::Constant(box self.constant.clone());
374+
*operand = Operand::Constant(box self.constant);
375375
self.uses_replaced += 1
376376
}
377377
}

src/librustc_mir_build/build/expr/as_rvalue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
292292
let of_fld = Field::new(1);
293293

294294
let tcx = self.hir.tcx();
295-
let val = tcx.mk_place_field(result_value.clone(), val_fld, ty);
295+
let val = tcx.mk_place_field(result_value, val_fld, ty);
296296
let of = tcx.mk_place_field(result_value, of_fld, bool_ty);
297297

298298
let err = AssertKind::Overflow(op);

src/libstd/sync/mpsc/stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<T> Packet<T> {
329329
);
330330
cnt != DISCONNECTED && cnt != steals
331331
} {
332-
while let Some(_) = self.queue.pop() {
332+
while self.queue.pop().is_some() {
333333
steals += 1;
334334
}
335335
}

0 commit comments

Comments
 (0)