]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/strings.rs
Fix false positive in `string_add`.
[rust.git] / clippy_lints / src / strings.rs
index 00e2441becf8129f8b6e283fb7e23eea8e74daa2..c1d441c39358af24dfc00da36cefdb9f565b6f1f 100644 (file)
@@ -1,13 +1,16 @@
+use rustc::declare_lint_pass;
 use rustc::hir::*;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use rustc::{declare_lint_pass, declare_tool_lint};
 use rustc_errors::Applicability;
+use rustc_session::declare_tool_lint;
 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
 
 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, ..