mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-14 13:06:49 +00:00
Fix false positive in string_add
.
This commit is contained in:
parent
374db5c0b7
commit
d11b958faf
@ -8,7 +8,9 @@ use syntax::source_map::Spanned;
|
||||
use if_chain::if_chain;
|
||||
|
||||
use crate::utils::SpanlessEq;
|
||||
use crate::utils::{get_parent_expr, is_allowed, match_type, paths, span_lint, span_lint_and_sugg, walk_ptrs_ty};
|
||||
use crate::utils::{
|
||||
get_parent_expr, in_macro, is_allowed, match_type, paths, span_lint, span_lint_and_sugg, walk_ptrs_ty,
|
||||
};
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// **What it does:** Checks for string appends of the form `x = x + y` (without
|
||||
@ -80,6 +82,10 @@ declare_lint_pass!(StringAdd => [STRING_ADD, STRING_ADD_ASSIGN]);
|
||||
|
||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for StringAdd {
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, e: &'tcx Expr) {
|
||||
if in_macro(e.span) {
|
||||
return;
|
||||
}
|
||||
|
||||
if let ExprKind::Binary(
|
||||
Spanned {
|
||||
node: BinOpKind::Add, ..
|
||||
|
@ -16,4 +16,13 @@ fn main() {
|
||||
let mut x = 1;
|
||||
x = x + 1;
|
||||
assert_eq!(2, x);
|
||||
|
||||
macro_rules! mac {
|
||||
() => {
|
||||
let y = "".to_owned();
|
||||
let z = y + "...";
|
||||
};
|
||||
}
|
||||
|
||||
mac!();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user