mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
parent
c0c770c60b
commit
867ac98d38
@ -1,7 +1,8 @@
|
||||
use crate::syntax::ast::*;
|
||||
use crate::rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
|
||||
use crate::rustc::{declare_tool_lint, lint_array};
|
||||
use crate::utils::span_lint;
|
||||
use crate::utils::{in_macro, span_lint};
|
||||
|
||||
|
||||
/// **What it does:** Checks for unnecessary double parentheses.
|
||||
///
|
||||
@ -33,6 +34,10 @@ impl LintPass for DoubleParens {
|
||||
|
||||
impl EarlyLintPass for DoubleParens {
|
||||
fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
|
||||
if in_macro(expr.span) {
|
||||
return;
|
||||
}
|
||||
|
||||
match expr.node {
|
||||
ExprKind::Paren(ref in_paren) => match in_paren.node {
|
||||
ExprKind::Paren(_) | ExprKind::Tup(_) => {
|
||||
|
@ -48,4 +48,10 @@ fn method_unit_ok(x: DummyStruct) {
|
||||
x.dummy_method(());
|
||||
}
|
||||
|
||||
// Issue #3206
|
||||
fn inside_macro() {
|
||||
assert_eq!((1, 2), (1, 2), "Error");
|
||||
assert_eq!(((1, 2)), (1, 2), "Error");
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -30,5 +30,11 @@ error: Consider removing unnecessary double parentheses
|
||||
32 | (())
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: Consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:54:16
|
||||
|
|
||||
54 | assert_eq!(((1, 2)), (1, 2), "Error");
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user