]> git.lizzy.rs Git - rust.git/commitdiff
Address things complained about by clippy
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 5 May 2017 08:34:38 +0000 (10:34 +0200)
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 5 May 2017 08:34:38 +0000 (10:34 +0200)
src/bin/miri.rs
src/eval_context.rs
src/lvalue.rs
src/terminator/drop.rs
tests/compiletest.rs

index 0c3424bc52b88c2a2e0a5622d74ef49b62ca42fa..3f0a6f778b4254d06a41c088d5e58279c9c937e8 100644 (file)
@@ -93,15 +93,13 @@ fn visit_trait_item(&mut self, _trait_item: &'hir hir::TraitItem) {}
             fn visit_impl_item(&mut self, _impl_item: &'hir hir::ImplItem) {}
         }
         state.hir_crate.unwrap().visit_all_item_likes(&mut Visitor(limits, tcx, state));
-    } else {
-        if let Some((entry_node_id, _)) = *state.session.entry_fn.borrow() {
-            let entry_def_id = tcx.hir.local_def_id(entry_node_id);
-            miri::eval_main(tcx, entry_def_id, limits);
+    } else if let Some((entry_node_id, _)) = *state.session.entry_fn.borrow() {
+        let entry_def_id = tcx.hir.local_def_id(entry_node_id);
+        miri::eval_main(tcx, entry_def_id, limits);
 
-            state.session.abort_if_errors();
-        } else {
-            println!("no main function found, assuming auxiliary build");
-        }
+        state.session.abort_if_errors();
+    } else {
+        println!("no main function found, assuming auxiliary build");
     }
 }
 
index 1dfca553c749f66124b6ef73e9da2eae1d0a63f8..b9aa499015a8f4008a1b61c65e25ffa29871f20a 100644 (file)
@@ -1023,7 +1023,7 @@ pub(super) fn eval_operand(&mut self, op: &mir::Operand<'tcx>) -> EvalResult<'tc
     }
 
     pub(super) fn operand_ty(&self, operand: &mir::Operand<'tcx>) -> Ty<'tcx> {
-        self.monomorphize(operand.ty(&self.mir(), self.tcx), self.substs())
+        self.monomorphize(operand.ty(self.mir(), self.tcx), self.substs())
     }
 
     fn copy(&mut self, src: Pointer, dest: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx> {
index 0f1ce103b0c44f702e133d81c2e6166e22125a21..9660b8f4eec8605e74364ab49fe6dd285a5b3072 100644 (file)
@@ -399,6 +399,6 @@ fn eval_lvalue_projection(
     }
 
     pub(super) fn lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> {
-        self.monomorphize(lvalue.ty(&self.mir(), self.tcx).to_ty(self.tcx), self.substs())
+        self.monomorphize(lvalue.ty(self.mir(), self.tcx).to_ty(self.tcx), self.substs())
     }
 }
index 8ce57ba44c78fd4fd03468362d7bd91626a9b1b1..93dfe408e31a989f88145a01ef2bcb2cbbe267f6 100644 (file)
@@ -53,13 +53,13 @@ pub(crate) fn drop(&mut self, mut arg: Value, mut instance: ty::Instance<'tcx>,
                     _ => bug!("expected thin ptr, got {:?}", arg),
                 };
                 arg = Value::ByValPair(PrimVal::Ptr(ptr), PrimVal::Bytes(n as u128));
-                &self.seq_drop_glue
+                self.seq_drop_glue
             },
             ty::TySlice(elem) => {
                 instance.substs = self.tcx.mk_substs([
                     Kind::from(elem),
                 ].iter().cloned());
-                &self.seq_drop_glue
+                self.seq_drop_glue
             },
             _ => self.load_mir(instance.def)?,
         };
index 6e5890d6ade00e485b7d1e25d6b23e756341c649..78b2a2f3ce252d09ca0dc78c17143e6b041c14ae 100644 (file)
@@ -5,7 +5,7 @@
 
 fn compile_fail(sysroot: &Path) {
     let flags = format!("--sysroot {} -Dwarnings", sysroot.to_str().expect("non utf8 path"));
-    for_all_targets(&sysroot, |target| {
+    for_all_targets(sysroot, |target| {
         let mut config = compiletest::default_config();
         config.host_rustcflags = Some(flags.clone());
         config.mode = "compile-fail".parse().expect("Invalid mode");
@@ -79,8 +79,8 @@ fn compile_test() {
         .expect("rustc not found for -vV")
         .stdout;
     let host = std::str::from_utf8(&host).expect("sysroot is not utf8");
-    let host = host.split("\nhost: ").skip(1).next().expect("no host: part in rustc -vV");
-    let host = host.split("\n").next().expect("no \n after host");
+    let host = host.split("\nhost: ").nth(1).expect("no host: part in rustc -vV");
+    let host = host.split('\n').next().expect("no \n after host");
 
     if let Ok(path) = std::env::var("MIRI_RUSTC_TEST") {
         let mut mir_not_found = Vec::new();
@@ -148,10 +148,8 @@ fn compile_test() {
                                 abi.push(text[abi_s.len()..end].to_string());
                             } else if text.starts_with(limit_s) {
                                 limits.push(text[limit_s.len()..end].to_string());
-                            } else {
-                                if text.find("aborting").is_none() {
-                                    failed.push(text[..end].to_string());
-                                }
+                            } else if text.find("aborting").is_none() {
+                                failed.push(text[..end].to_string());
                             }
                         }
                         writeln!(stderr.lock(), "FAILED with exit code {:?}", output.status.code()).unwrap();
@@ -196,10 +194,10 @@ fn compile_test() {
         panic!("ran miri on rustc test suite. Test failing for convenience");
     } else {
         run_pass();
-        for_all_targets(&sysroot, |target| {
+        for_all_targets(sysroot, |target| {
             miri_pass("tests/run-pass", &target, host);
         });
-        compile_fail(&sysroot);
+        compile_fail(sysroot);
     }
 }
 
@@ -218,7 +216,7 @@ fn vec_to_hist<T: PartialEq + Ord>(mut v: Vec<T>) -> Vec<(usize, T)> {
     let mut current = v.next();
     'outer: while let Some(current_val) = current {
         let mut n = 1;
-        while let Some(next) = v.next() {
+        for next in &mut v {
             if next == current_val {
                 n += 1;
             } else {