double-parens: make lint adhere to lint message convention and do minor refactoring
This commit is contained in:
parent
ba7a01a6a8
commit
590b91d8d4
@ -45,15 +45,12 @@ impl EarlyLintPass for DoubleParens {
|
||||
return;
|
||||
}
|
||||
|
||||
let msg: &str = "consider removing unnecessary double parentheses";
|
||||
|
||||
match expr.kind {
|
||||
ExprKind::Paren(ref in_paren) => match in_paren.kind {
|
||||
ExprKind::Paren(_) | ExprKind::Tup(_) => {
|
||||
span_lint(
|
||||
cx,
|
||||
DOUBLE_PARENS,
|
||||
expr.span,
|
||||
"Consider removing unnecessary double parentheses",
|
||||
);
|
||||
span_lint(cx, DOUBLE_PARENS, expr.span, &msg);
|
||||
},
|
||||
_ => {},
|
||||
},
|
||||
@ -61,12 +58,7 @@ impl EarlyLintPass for DoubleParens {
|
||||
if params.len() == 1 {
|
||||
let param = ¶ms[0];
|
||||
if let ExprKind::Paren(_) = param.kind {
|
||||
span_lint(
|
||||
cx,
|
||||
DOUBLE_PARENS,
|
||||
param.span,
|
||||
"Consider removing unnecessary double parentheses",
|
||||
);
|
||||
span_lint(cx, DOUBLE_PARENS, param.span, &msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -74,12 +66,7 @@ impl EarlyLintPass for DoubleParens {
|
||||
if params.len() == 2 {
|
||||
let param = ¶ms[1];
|
||||
if let ExprKind::Paren(_) = param.kind {
|
||||
span_lint(
|
||||
cx,
|
||||
DOUBLE_PARENS,
|
||||
param.span,
|
||||
"Consider removing unnecessary double parentheses",
|
||||
);
|
||||
span_lint(cx, DOUBLE_PARENS, param.span, &msg);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
error: Consider removing unnecessary double parentheses
|
||||
error: consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:15:5
|
||||
|
|
||||
LL | ((0))
|
||||
@ -6,31 +6,31 @@ LL | ((0))
|
||||
|
|
||||
= note: `-D clippy::double-parens` implied by `-D warnings`
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
error: consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:19:14
|
||||
|
|
||||
LL | dummy_fn((0));
|
||||
| ^^^
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
error: consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:23:20
|
||||
|
|
||||
LL | x.dummy_method((0));
|
||||
| ^^^
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
error: consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:27:5
|
||||
|
|
||||
LL | ((1, 2))
|
||||
| ^^^^^^^^
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
error: consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:31:5
|
||||
|
|
||||
LL | (())
|
||||
| ^^^^
|
||||
|
||||
error: Consider removing unnecessary double parentheses
|
||||
error: consider removing unnecessary double parentheses
|
||||
--> $DIR/double_parens.rs:53:16
|
||||
|
|
||||
LL | assert_eq!(((1, 2)), (1, 2), "Error");
|
||||
|
Loading…
Reference in New Issue
Block a user