Fix warnings of compiler_lint_functions
This commit is contained in:
parent
aaeeaa5330
commit
a4e1a90705
@ -1,6 +1,7 @@
|
|||||||
use crate::syntax::ast::*;
|
use crate::syntax::ast::*;
|
||||||
use crate::rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
|
use crate::rustc::lint::{EarlyContext, EarlyLintPass, LintArray, LintPass};
|
||||||
use crate::rustc::{declare_tool_lint, lint_array};
|
use crate::rustc::{declare_tool_lint, lint_array};
|
||||||
|
use crate::utils::span_lint;
|
||||||
|
|
||||||
/// **What it does:** Checks for unnecessary double parentheses.
|
/// **What it does:** Checks for unnecessary double parentheses.
|
||||||
///
|
///
|
||||||
@ -35,20 +36,20 @@ impl EarlyLintPass for DoubleParens {
|
|||||||
match expr.node {
|
match expr.node {
|
||||||
ExprKind::Paren(ref in_paren) => match in_paren.node {
|
ExprKind::Paren(ref in_paren) => match in_paren.node {
|
||||||
ExprKind::Paren(_) | ExprKind::Tup(_) => {
|
ExprKind::Paren(_) | ExprKind::Tup(_) => {
|
||||||
cx.span_lint(DOUBLE_PARENS, expr.span, "Consider removing unnecessary double parentheses");
|
span_lint(cx, DOUBLE_PARENS, expr.span, "Consider removing unnecessary double parentheses");
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
},
|
},
|
||||||
ExprKind::Call(_, ref params) => if params.len() == 1 {
|
ExprKind::Call(_, ref params) => if params.len() == 1 {
|
||||||
let param = ¶ms[0];
|
let param = ¶ms[0];
|
||||||
if let ExprKind::Paren(_) = param.node {
|
if let ExprKind::Paren(_) = param.node {
|
||||||
cx.span_lint(DOUBLE_PARENS, param.span, "Consider removing unnecessary double parentheses");
|
span_lint(cx, DOUBLE_PARENS, param.span, "Consider removing unnecessary double parentheses");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprKind::MethodCall(_, ref params) => if params.len() == 2 {
|
ExprKind::MethodCall(_, ref params) => if params.len() == 2 {
|
||||||
let param = ¶ms[1];
|
let param = ¶ms[1];
|
||||||
if let ExprKind::Paren(_) = param.node {
|
if let ExprKind::Paren(_) = param.node {
|
||||||
cx.span_lint(DOUBLE_PARENS, param.span, "Consider removing unnecessary double parentheses");
|
span_lint(cx, DOUBLE_PARENS, param.span, "Consider removing unnecessary double parentheses");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
|
Loading…
Reference in New Issue
Block a user