mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
Add clarifying pattern lint comment and revert test
This commit is contained in:
@@ -377,6 +377,10 @@ fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
|
||||
|
||||
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(..) => {}
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
// run-pass
|
||||
|
||||
fn main() {
|
||||
#[allow(unused_parens)]
|
||||
match 0 {
|
||||
pat => assert_eq!(pat, 0)
|
||||
(pat) => assert_eq!(pat, 0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user