Skip to content

Commit 0e411c2

Browse files
committed
Add clarifying pattern lint comment and revert test
1 parent 47014df commit 0e411c2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustc_lint/unused.rs

+4
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@ impl EarlyLintPass for UnusedParens {
377377

378378
fn check_pat(&mut self, cx: &EarlyContext, p: &ast::Pat) {
379379
use ast::PatKind::{Paren, Range};
380+
// The lint visitor will visit each subpattern of `p`. We do not want to lint any range
381+
// pattern no matter where it occurs in the pattern. For something like `&(a..=b)`, there
382+
// is a recursive `check_pat` on `a` and `b`, but we will assume that if there are
383+
// unnecessry parens they serve a purpose of readability.
380384
if let Paren(ref pat) = p.node {
381385
match pat.node {
382386
Range(..) => {}

src/test/run-pass/binding/pat-tuple-7.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
// run-pass
1212

1313
fn main() {
14+
#[allow(unused_parens)]
1415
match 0 {
15-
pat => assert_eq!(pat, 0)
16+
(pat) => assert_eq!(pat, 0)
1617
}
1718
}

0 commit comments

Comments
 (0)