|
1 | 1 | use clippy_utils::diagnostics::span_lint_and_then;
|
2 | 2 | use clippy_utils::macros::macro_backtrace;
|
| 3 | +use rustc_ast::Attribute; |
3 | 4 | use rustc_data_structures::fx::FxHashSet;
|
4 | 5 | use rustc_hir::def_id::DefIdMap;
|
5 |
| -use rustc_hir::{Expr, ForeignItem, HirId, ImplItem, Item, Pat, Path, Stmt, TraitItem, Ty}; |
| 6 | +use rustc_hir::{Expr, ExprKind, ForeignItem, HirId, ImplItem, Item, Pat, Path, Stmt, TraitItem, Ty}; |
6 | 7 | use rustc_lint::{LateContext, LateLintPass};
|
7 | 8 | use rustc_session::{declare_tool_lint, impl_lint_pass};
|
8 | 9 | use rustc_span::{ExpnId, Span};
|
@@ -111,6 +112,10 @@ impl LateLintPass<'_> for DisallowedMacros {
|
111 | 112 |
|
112 | 113 | fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
113 | 114 | self.check(cx, expr.span);
|
| 115 | + // `$t + $t` can have the context of $t, check also the span of the binary operator |
| 116 | + if let ExprKind::Binary(op, ..) = expr.kind { |
| 117 | + self.check(cx, op.span) |
| 118 | + } |
114 | 119 | }
|
115 | 120 |
|
116 | 121 | fn check_stmt(&mut self, cx: &LateContext<'_>, stmt: &Stmt<'_>) {
|
@@ -147,4 +152,8 @@ impl LateLintPass<'_> for DisallowedMacros {
|
147 | 152 | fn check_path(&mut self, cx: &LateContext<'_>, path: &Path<'_>, _: HirId) {
|
148 | 153 | self.check(cx, path.span);
|
149 | 154 | }
|
| 155 | + |
| 156 | + fn check_attribute(&mut self, cx: &LateContext<'_>, attr: &Attribute) { |
| 157 | + self.check(cx, attr.span); |
| 158 | + } |
150 | 159 | }
|
0 commit comments