]> git.lizzy.rs Git - rust.git/commitdiff
fix more clippy warnings
authorMatthias Krüger <matthias.krueger@famsik.de>
Sat, 25 Apr 2020 08:17:14 +0000 (10:17 +0200)
committerMatthias Krüger <matthias.krueger@famsik.de>
Sun, 26 Apr 2020 00:24:01 +0000 (02:24 +0200)
clippy::{redundant_pattern_matching, clone_on_copy, iter_cloned_collect, option_as_ref_deref, match_ref_pats}

src/liballoc/collections/binary_heap.rs
src/liballoc/collections/linked_list.rs
src/librustc_driver/lib.rs
src/librustc_interface/util.rs
src/librustc_metadata/rmeta/decoder/cstore_impl.rs
src/librustc_mir/transform/copy_prop.rs
src/librustc_mir_build/build/expr/as_rvalue.rs
src/libstd/sync/mpsc/stream.rs

index 8e170d970bc57260d9915274ed41170f72957d50..a3ef9989184336fb20881b878e26aa5c2f2a8d8c 100644 (file)
@@ -1269,7 +1269,7 @@ fn drop(&mut self) {
 
         impl<'r, 'a, T: Ord> Drop for DropGuard<'r, 'a, T> {
             fn drop(&mut self) {
-                while let Some(_) = self.0.inner.pop() {}
+                while self.0.inner.pop().is_some() {}
             }
         }
 
index 9dd7fc6d7ee789c11fdfbeedfebe4f657b1a218e..bfa4045787f5b7141d98addc638f8a1392c0c9fb 100644 (file)
@@ -972,7 +972,7 @@ impl<'a, T> Drop for DropGuard<'a, T> {
             fn drop(&mut self) {
                 // Continue the same loop we do below. This only runs when a destructor has
                 // panicked. If another one panics this will abort.
-                while let Some(_) = self.0.pop_front_node() {}
+                while self.0.pop_front_node().is_some() {}
             }
         }
 
index fff86ba819450fa71235be72f013ba409c576332..913ccf8e68089ab6bab489539858986eba9ac2ab 100644 (file)
@@ -618,15 +618,15 @@ pub fn list_metadata(
     ) -> Compilation {
         let r = matches.opt_strs("Z");
         if r.iter().any(|s| *s == "ls") {
-            match input {
-                &Input::File(ref ifile) => {
+            match *input {
+                Input::File(ref ifile) => {
                     let path = &(*ifile);
                     let mut v = Vec::new();
                     locator::list_file_metadata(&sess.target.target, path, metadata_loader, &mut v)
                         .unwrap();
                     println!("{}", String::from_utf8(v).unwrap());
                 }
-                &Input::Str { .. } => {
+                Input::Str { .. } => {
                     early_error(ErrorOutputType::default(), "cannot list metadata for stdin");
                 }
             }
index fda0172544333bc6ed630bc8786b318b07f06182..367dc4dee7ee034800d4ecc95b6f4d87f6141560 100644 (file)
@@ -625,8 +625,8 @@ fn involves_impl_trait(ty: &ast::Ty) -> bool {
                     | ast::TyKind::Rptr(_, ast::MutTy { ty: ref subty, .. })
                     | ast::TyKind::Paren(ref subty) => involves_impl_trait(subty),
                     ast::TyKind::Tup(ref tys) => any_involves_impl_trait(tys.iter()),
-                    ast::TyKind::Path(_, ref path) => path.segments.iter().any(|seg| {
-                        match seg.args.as_ref().map(|generic_arg| &**generic_arg) {
+                    ast::TyKind::Path(_, ref path) => {
+                        path.segments.iter().any(|seg| match seg.args.as_deref() {
                             None => false,
                             Some(&ast::GenericArgs::AngleBracketed(ref data)) => {
                                 data.args.iter().any(|arg| match arg {
@@ -647,8 +647,8 @@ fn involves_impl_trait(ty: &ast::Ty) -> bool {
                                 any_involves_impl_trait(data.inputs.iter())
                                     || ReplaceBodyWithLoop::should_ignore_fn(&data.output)
                             }
-                        }
-                    }),
+                        })
+                    }
                     _ => false,
                 }
             }
index ecf3825dadb2d8fd77fc174a6d7dce07e1e8f44c..7d1639cbcf7a1791d2a03d43eee9f0572a1e16ce 100644 (file)
@@ -431,7 +431,7 @@ pub fn load_macro_untracked(&self, id: DefId, sess: &Session) -> LoadedMacro {
                 ident,
                 id: ast::DUMMY_NODE_ID,
                 span,
-                attrs: attrs.iter().cloned().collect(),
+                attrs: attrs.to_vec(),
                 kind: ast::ItemKind::MacroDef(data.get_macro(id.index, sess)),
                 vis: source_map::respan(span.shrink_to_lo(), ast::VisibilityKind::Inherited),
                 tokens: None,
index bc1cb52ae855f8ce0ac43bbd36ea06459788fe8f..b9eb58f800e5c0d388af07cec6e054e0df8e3015 100644 (file)
@@ -246,7 +246,7 @@ fn local_copy(
     }
 
     fn constant(src_constant: &Constant<'tcx>) -> Option<Action<'tcx>> {
-        Some(Action::PropagateConstant((*src_constant).clone()))
+        Some(Action::PropagateConstant(*src_constant))
     }
 
     fn perform(
@@ -371,7 +371,7 @@ fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
             _ => return,
         }
 
-        *operand = Operand::Constant(box self.constant.clone());
+        *operand = Operand::Constant(box self.constant);
         self.uses_replaced += 1
     }
 }
index b6f46aab4161268adc99f681dd260b4d6e22b3f3..38f71135c7d928558df37a5e8d98ed0c4992d048 100644 (file)
@@ -292,7 +292,7 @@ fn expr_as_rvalue(
             let of_fld = Field::new(1);
 
             let tcx = self.hir.tcx();
-            let val = tcx.mk_place_field(result_value.clone(), val_fld, ty);
+            let val = tcx.mk_place_field(result_value, val_fld, ty);
             let of = tcx.mk_place_field(result_value, of_fld, bool_ty);
 
             let err = AssertKind::Overflow(op);
index 26b4faebd861420957431d3c117ee90eedd53336..9f7c1af8951991500723eafd6e6ed16b27d1134c 100644 (file)
@@ -329,7 +329,7 @@ pub fn drop_port(&self) {
             );
             cnt != DISCONNECTED && cnt != steals
         } {
-            while let Some(_) = self.queue.pop() {
+            while self.queue.pop().is_some() {
                 steals += 1;
             }
         }