about summary refs log tree commit diff
path: root/src/libtest/lib.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-07-04 02:18:46 -0700
committerGitHub <noreply@github.com>2016-07-04 02:18:46 -0700
commitd508de6cf7c7bb9b5057ee63432dbbc899209101 (patch)
tree972fd7fd823fc411d3d3a175bbae46dee2f6d71b /src/libtest/lib.rs
parentd98da85c5cfd2546ac711701cecc05b093242a26 (diff)
parentd37edef9dd088d953c5e272db37686a338c31778 (diff)
downloadrust-d508de6cf7c7bb9b5057ee63432dbbc899209101.tar.gz
rust-d508de6cf7c7bb9b5057ee63432dbbc899209101.zip
Auto merge of #34638 - zackmdavis:if_let_over_none_empty_block_arm, r=jseyfried
prefer `if let` to match with `None => {}` arm in some places

This is a spiritual succesor to #34268 / 8531d581, in which we replaced a
number of matches of None to the unit value with `if let` conditionals
where it was judged that this made for clearer/simpler code (as would be
recommended by Manishearth/rust-clippy's `single_match` lint). The same
rationale applies to matches of None to the empty block.

----

r? @jseyfried
Diffstat (limited to 'src/libtest/lib.rs')
-rw-r--r--src/libtest/lib.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs
index 88be3ade839..c90c93e75ac 100644
--- a/src/libtest/lib.rs
+++ b/src/libtest/lib.rs
@@ -747,12 +747,9 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
             PadOnRight => t.desc.name.as_slice().len(),
         }
     }
-    match tests.iter().max_by_key(|t| len_if_padded(*t)) {
-        Some(t) => {
-            let n = t.desc.name.as_slice();
-            st.max_name_len = n.len();
-        }
-        None => {}
+    if let Some(t) = tests.iter().max_by_key(|t| len_if_padded(*t)) {
+        let n = t.desc.name.as_slice();
+        st.max_name_len = n.len();
     }
     run_tests(opts, tests, |x| callback(&x, &mut st))?;
     return st.write_run_finish();