]> git.lizzy.rs Git - rust.git/commitdiff
Fix some clippy issues
authorJoshua Nelson <jyn514@gmail.com>
Thu, 1 Oct 2020 05:23:08 +0000 (01:23 -0400)
committerJoshua Nelson <jyn514@gmail.com>
Thu, 1 Oct 2020 05:34:38 +0000 (01:34 -0400)
Found while working on https://github.com/rust-lang/rust/pull/77351;
these are just the ones that could be fixed automatically.

library/test/src/bench.rs
library/test/src/formatters/pretty.rs
library/test/src/formatters/terse.rs
library/test/src/lib.rs
library/test/src/stats.rs

index a03cf9dd791156077329232a1be4e3e36ee7a96b..10546de17641ddb17ece871e5dd66b843912c874 100644 (file)
@@ -159,7 +159,7 @@ pub fn iter<T, F>(inner: &mut F) -> stats::Summary
             return summ5;
         }
 
-        total_run = total_run + loop_run;
+        total_run += loop_run;
         // Longest we ever run for is 3s.
         if total_run > Duration::from_secs(3) {
             return summ5;
index 4a93e084df178d8182ec03bf4c111d7e47e3654b..8c90b57b3bac3fa420388446c7db57241d3989f3 100644 (file)
@@ -139,7 +139,7 @@ fn write_results(
                 stdouts.push_str(&format!("---- {} stdout ----\n", f.name));
                 let output = String::from_utf8_lossy(stdout);
                 stdouts.push_str(&output);
-                stdouts.push_str("\n");
+                stdouts.push('\n');
             }
         }
         if !stdouts.is_empty() {
index 5a264d2005744cb54faeef7c8fcbb8a8ebb34b9c..1ae7846a99e3a1ffee1cb87c2210c3cc34c54199 100644 (file)
@@ -114,7 +114,7 @@ pub fn write_outputs(&mut self, state: &ConsoleTestState) -> io::Result<()> {
                 stdouts.push_str(&format!("---- {} stdout ----\n", f.name));
                 let output = String::from_utf8_lossy(stdout);
                 stdouts.push_str(&output);
-                stdouts.push_str("\n");
+                stdouts.push('\n');
             }
         }
         if !stdouts.is_empty() {
@@ -140,7 +140,7 @@ pub fn write_failures(&mut self, state: &ConsoleTestState) -> io::Result<()> {
                 fail_out.push_str(&format!("---- {} stdout ----\n", f.name));
                 let output = String::from_utf8_lossy(stdout);
                 fail_out.push_str(&output);
-                fail_out.push_str("\n");
+                fail_out.push('\n');
             }
         }
         if !fail_out.is_empty() {
index caea4b1e3094162593310c64f32d8340fb11c578..b0b81f85fe08fe12c3a0d0eb4fb624a2fab92ce9 100644 (file)
@@ -237,11 +237,9 @@ pub fn run_tests<F>(
     let event = TestEvent::TeFiltered(filtered_descs);
     notify_about_test_event(event)?;
 
-    let (filtered_tests, filtered_benchs): (Vec<_>, _) =
-        filtered_tests.into_iter().partition(|e| match e.testfn {
-            StaticTestFn(_) | DynTestFn(_) => true,
-            _ => false,
-        });
+    let (filtered_tests, filtered_benchs): (Vec<_>, _) = filtered_tests
+        .into_iter()
+        .partition(|e| matches!(e.testfn, StaticTestFn(_) | DynTestFn(_)));
 
     let concurrency = opts.test_threads.unwrap_or_else(get_concurrency);
 
index 1a2cb893a8a4fc551807c4750d2d5c82ceecdec4..53f3889447453fa810126ed8dd78f1de9e74fca3 100644 (file)
@@ -199,7 +199,7 @@ fn var(&self) -> f64 {
             let mut v: f64 = 0.0;
             for s in self {
                 let x = *s - mean;
-                v = v + x * x;
+                v += x * x;
             }
             // N.B., this is _supposed to be_ len-1, not len. If you
             // change it back to len, you will be calculating a