about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKevin Leimkuhler <kevin@kleimkuhler.com>2018-10-09 17:37:45 -0700
committerKevin Leimkuhler <kevin@kleimkuhler.com>2018-10-09 21:10:27 -0700
commit0e411c2597dcfe75dd76acefcecec916a950ac6e (patch)
treeb34d90865fd580525245ffd75f45e86a65a42944
parent47014df79083f837323aa60021b893d2a33a9828 (diff)
downloadrust-0e411c2597dcfe75dd76acefcecec916a950ac6e.tar.gz
rust-0e411c2597dcfe75dd76acefcecec916a950ac6e.zip
Add clarifying pattern lint comment and revert test
-rw-r--r--src/librustc_lint/unused.rs4
-rw-r--r--src/test/run-pass/binding/pat-tuple-7.rs3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs
index 050e52d2e0c..297b60d5728 100644
--- a/src/librustc_lint/unused.rs
+++ b/src/librustc_lint/unused.rs
@@ -377,6 +377,10 @@ impl EarlyLintPass for UnusedParens {
 
     fn check_pat(&mut self, cx: &EarlyContext, p: &ast::Pat) {
         use ast::PatKind::{Paren, Range};
+        // The lint visitor will visit each subpattern of `p`. We do not want to lint any range
+        // pattern no matter where it occurs in the pattern. For something like `&(a..=b)`, there
+        // is a recursive `check_pat` on `a` and `b`, but we will assume that if there are
+        // unnecessry parens they serve a purpose of readability.
         if let Paren(ref pat) = p.node {
             match pat.node {
                 Range(..) => {}
diff --git a/src/test/run-pass/binding/pat-tuple-7.rs b/src/test/run-pass/binding/pat-tuple-7.rs
index f02e3198984..06bd14d188e 100644
--- a/src/test/run-pass/binding/pat-tuple-7.rs
+++ b/src/test/run-pass/binding/pat-tuple-7.rs
@@ -11,7 +11,8 @@
 // run-pass
 
 fn main() {
+    #[allow(unused_parens)]
     match 0 {
-        pat => assert_eq!(pat, 0)
+        (pat) => assert_eq!(pat, 0)
     }
 }