get snippets inside the suggestions-closure
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use rustc::hir;
|
use rustc::hir;
|
||||||
use rustc::lint::*;
|
use rustc::lint::*;
|
||||||
use utils::{span_lint_and_then, span_lint, snippet_opt, SpanlessEq, get_trait_def_id, implements_trait};
|
use utils::{span_lint_and_then, snippet_opt, SpanlessEq, get_trait_def_id, implements_trait};
|
||||||
use utils::{higher, sugg};
|
use utils::{higher, sugg};
|
||||||
|
|
||||||
/// **What it does:** This lint checks for `+=` operations and similar.
|
/// **What it does:** This lint checks for `+=` operations and similar.
|
||||||
@@ -104,23 +104,18 @@ impl LateLintPass for AssignOps {
|
|||||||
BitXor: BiBitXor,
|
BitXor: BiBitXor,
|
||||||
Shr: BiShr,
|
Shr: BiShr,
|
||||||
Shl: BiShl) {
|
Shl: BiShl) {
|
||||||
if let (Some(snip_a), Some(snip_r)) = (snippet_opt(cx, assignee.span),
|
|
||||||
snippet_opt(cx, rhs.span)) {
|
|
||||||
span_lint_and_then(cx,
|
span_lint_and_then(cx,
|
||||||
ASSIGN_OP_PATTERN,
|
ASSIGN_OP_PATTERN,
|
||||||
expr.span,
|
expr.span,
|
||||||
"manual implementation of an assign operation",
|
"manual implementation of an assign operation",
|
||||||
|db| {
|
|db| {
|
||||||
|
if let (Some(snip_a), Some(snip_r)) = (snippet_opt(cx, assignee.span),
|
||||||
|
snippet_opt(cx, rhs.span)) {
|
||||||
db.span_suggestion(expr.span,
|
db.span_suggestion(expr.span,
|
||||||
"replace it with",
|
"replace it with",
|
||||||
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r));
|
format!("{} {}= {}", snip_a, op.node.as_str(), snip_r));
|
||||||
});
|
|
||||||
} else {
|
|
||||||
span_lint(cx,
|
|
||||||
ASSIGN_OP_PATTERN,
|
|
||||||
expr.span,
|
|
||||||
"manual implementation of an assign operation");
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// a = a op b
|
// a = a op b
|
||||||
|
|||||||
Reference in New Issue
Block a user