Use span_lint_and_sugg
This commit is contained in:
parent
88101d5b78
commit
745233f3ab
12 changed files with 91 additions and 122 deletions
|
@ -1,6 +1,6 @@
|
|||
use syntax::ast::{Expr, ExprKind, UnOp};
|
||||
use rustc::lint::*;
|
||||
use utils::{span_lint_and_then, snippet};
|
||||
use utils::{span_lint_and_sugg, snippet};
|
||||
|
||||
/// **What it does:** Checks for usage of `*&` and `*&mut` in expressions.
|
||||
///
|
||||
|
@ -40,9 +40,8 @@ impl EarlyLintPass for Pass {
|
|||
fn check_expr(&mut self, cx: &EarlyContext, e: &Expr) {
|
||||
if let ExprKind::Unary(UnOp::Deref, ref deref_target) = e.node {
|
||||
if let ExprKind::AddrOf(_, ref addrof_target) = without_parens(deref_target).node {
|
||||
span_lint_and_then(cx, DEREF_ADDROF, e.span, "immediately dereferencing a reference", |db| {
|
||||
db.span_suggestion(e.span, "try this", format!("{}", snippet(cx, addrof_target.span, "_")));
|
||||
});
|
||||
span_lint_and_sugg(cx, DEREF_ADDROF, e.span, "immediately dereferencing a reference",
|
||||
"try this", format!("{}", snippet(cx, addrof_target.span, "_")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue