Skip to content

Commit

Permalink
Add clarifying pattern lint comment and revert test
Browse files Browse the repository at this point in the history
  • Loading branch information
kleimkuhler committed Oct 10, 2018
1 parent 47014df commit 0e411c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/librustc_lint/unused.rs
Expand Up @@ -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(..) => {}
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-pass/binding/pat-tuple-7.rs
Expand Up @@ -11,7 +11,8 @@
// run-pass

fn main() {
#[allow(unused_parens)]
match 0 {
pat => assert_eq!(pat, 0)
(pat) => assert_eq!(pat, 0)
}
}

0 comments on commit 0e411c2

Please sign in to comment.