diff options
| author | Aaron Hill <aa1ronham@gmail.com> | 2021-07-15 14:26:27 -0500 |
|---|---|---|
| committer | Aaron Hill <aa1ronham@gmail.com> | 2021-07-17 23:03:58 -0500 |
| commit | d6e3c111011f6a270d56fdaf5222b484c4f38d65 (patch) | |
| tree | 84fdb9999073045b26dc61d405f78f9444e27c5e | |
| parent | 2bd15a25ef24949abbcfe066c04cd2a266410c47 (diff) | |
| download | rust-d6e3c111011f6a270d56fdaf5222b484c4f38d65.tar.gz rust-d6e3c111011f6a270d56fdaf5222b484c4f38d65.zip | |
Add additional missing lint handling logic
| -rw-r--r-- | compiler/rustc_expand/src/expand.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_lint/src/early.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/asm/inline-syntax.x86_64.stderr | 16 |
3 files changed, 20 insertions, 11 deletions
diff --git a/compiler/rustc_expand/src/expand.rs b/compiler/rustc_expand/src/expand.rs index f79e9648ab6..208894c3791 100644 --- a/compiler/rustc_expand/src/expand.rs +++ b/compiler/rustc_expand/src/expand.rs @@ -12,7 +12,7 @@ use rustc_ast::ptr::P; use rustc_ast::token; use rustc_ast::tokenstream::TokenStream; use rustc_ast::visit::{self, AssocCtxt, Visitor}; -use rustc_ast::{AstLike, Block, Inline, ItemKind, MacArgs}; +use rustc_ast::{AstLike, Block, Inline, ItemKind, Local, MacArgs}; use rustc_ast::{MacCallStmt, MacStmtStyle, MetaItemKind, ModKind, NestedMetaItem}; use rustc_ast::{NodeId, PatKind, Path, StmtKind, Unsafe}; use rustc_ast_pretty::pprust; @@ -1161,6 +1161,11 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { }); } + // This is needed in order to set `lint_node_id` for `let` statements + fn visit_local(&mut self, local: &mut P<Local>) { + assign_id!(self, &mut local.id, || noop_visit_local(local, self)); + } + fn flat_map_arm(&mut self, arm: ast::Arm) -> SmallVec<[ast::Arm; 1]> { let mut arm = configure!(self, arm); @@ -1307,6 +1312,8 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> { } // The placeholder expander gives ids to statements, so we avoid folding the id here. + // We don't use `assign_id!` - it will be called when we visit statement's contents + // (e.g. an expression, item, or local) let ast::Stmt { id, kind, span } = stmt; noop_flat_map_stmt_kind(kind, self) .into_iter() diff --git a/compiler/rustc_lint/src/early.rs b/compiler/rustc_lint/src/early.rs index 63e2f66f810..7a8b731da5c 100644 --- a/compiler/rustc_lint/src/early.rs +++ b/compiler/rustc_lint/src/early.rs @@ -210,8 +210,10 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T> } fn visit_arm(&mut self, a: &'a ast::Arm) { - run_early_pass!(self, check_arm, a); - ast_visit::walk_arm(self, a); + self.with_lint_attrs(a.id, &a.attrs, |cx| { + run_early_pass!(cx, check_arm, a); + ast_visit::walk_arm(cx, a); + }) } fn visit_expr_post(&mut self, e: &'a ast::Expr) { diff --git a/src/test/ui/asm/inline-syntax.x86_64.stderr b/src/test/ui/asm/inline-syntax.x86_64.stderr index a0e2a5ea0ef..dcbc17bb260 100644 --- a/src/test/ui/asm/inline-syntax.x86_64.stderr +++ b/src/test/ui/asm/inline-syntax.x86_64.stderr @@ -1,10 +1,16 @@ warning: avoid using `.intel_syntax`, Intel syntax is the default + --> $DIR/inline-syntax.rs:57:14 + | +LL | global_asm!(".intel_syntax noprefix", "nop"); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(bad_asm_style)]` on by default + +warning: avoid using `.intel_syntax`, Intel syntax is the default --> $DIR/inline-syntax.rs:31:15 | LL | asm!(".intel_syntax noprefix", "nop"); | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(bad_asm_style)]` on by default warning: avoid using `.intel_syntax`, Intel syntax is the default --> $DIR/inline-syntax.rs:34:15 @@ -36,11 +42,5 @@ warning: avoid using `.intel_syntax`, Intel syntax is the default LL | .intel_syntax noprefix | ^^^^^^^^^^^^^^^^^^^^^^ -warning: avoid using `.intel_syntax`, Intel syntax is the default - --> $DIR/inline-syntax.rs:57:14 - | -LL | global_asm!(".intel_syntax noprefix", "nop"); - | ^^^^^^^^^^^^^^^^^^^^^^ - warning: 7 warnings emitted |
