Skip to content

Commit d6e3c11

Browse files
committed
Add additional missing lint handling logic
1 parent 2bd15a2 commit d6e3c11

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

compiler/rustc_expand/src/expand.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_ast::ptr::P;
1212
use rustc_ast::token;
1313
use rustc_ast::tokenstream::TokenStream;
1414
use rustc_ast::visit::{self, AssocCtxt, Visitor};
15-
use rustc_ast::{AstLike, Block, Inline, ItemKind, MacArgs};
15+
use rustc_ast::{AstLike, Block, Inline, ItemKind, Local, MacArgs};
1616
use rustc_ast::{MacCallStmt, MacStmtStyle, MetaItemKind, ModKind, NestedMetaItem};
1717
use rustc_ast::{NodeId, PatKind, Path, StmtKind, Unsafe};
1818
use rustc_ast_pretty::pprust;
@@ -1161,6 +1161,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
11611161
});
11621162
}
11631163

1164+
// This is needed in order to set `lint_node_id` for `let` statements
1165+
fn visit_local(&mut self, local: &mut P<Local>) {
1166+
assign_id!(self, &mut local.id, || noop_visit_local(local, self));
1167+
}
1168+
11641169
fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> {
11651170
let mut arm = configure!(self, arm);
11661171

@@ -1307,6 +1312,8 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
13071312
}
13081313

13091314
// The placeholder expander gives ids to statements, so we avoid folding the id here.
1315+
// We don't use `assign_id!` - it will be called when we visit statement's contents
1316+
// (e.g. an expression, item, or local)
13101317
let ast::Stmt { id, kind, span } = stmt;
13111318
noop_flat_map_stmt_kind(kind, self)
13121319
.into_iter()

compiler/rustc_lint/src/early.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,10 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
210210
}
211211

212212
fn visit_arm(&mut self, a: &'a ast::Arm) {
213-
run_early_pass!(self, check_arm, a);
214-
ast_visit::walk_arm(self, a);
213+
self.with_lint_attrs(a.id, &a.attrs, |cx| {
214+
run_early_pass!(cx, check_arm, a);
215+
ast_visit::walk_arm(cx, a);
216+
})
215217
}
216218

217219
fn visit_expr_post(&mut self, e: &'a ast::Expr) {

src/test/ui/asm/inline-syntax.x86_64.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
warning: avoid using `.intel_syntax`, Intel syntax is the default
2+
--> $DIR/inline-syntax.rs:57:14
3+
|
4+
LL | global_asm!(".intel_syntax noprefix", "nop");
5+
| ^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: `#[warn(bad_asm_style)]` on by default
8+
19
warning: avoid using `.intel_syntax`, Intel syntax is the default
210
--> $DIR/inline-syntax.rs:31:15
311
|
412
LL | asm!(".intel_syntax noprefix", "nop");
513
| ^^^^^^^^^^^^^^^^^^^^^^
6-
|
7-
= note: `#[warn(bad_asm_style)]` on by default
814

915
warning: avoid using `.intel_syntax`, Intel syntax is the default
1016
--> $DIR/inline-syntax.rs:34:15
@@ -36,11 +42,5 @@ warning: avoid using `.intel_syntax`, Intel syntax is the default
3642
LL | .intel_syntax noprefix
3743
| ^^^^^^^^^^^^^^^^^^^^^^
3844

39-
warning: avoid using `.intel_syntax`, Intel syntax is the default
40-
--> $DIR/inline-syntax.rs:57:14
41-
|
42-
LL | global_asm!(".intel_syntax noprefix", "nop");
43-
| ^^^^^^^^^^^^^^^^^^^^^^
44-
4545
warning: 7 warnings emitted
4646

0 commit comments

Comments
 (0)