Add additional missing lint handling logic

This commit is contained in:
Aaron Hill 2021-07-15 14:26:27 -05:00
parent 2bd15a25ef
commit d6e3c11101
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
3 changed files with 20 additions and 11 deletions

View File

@ -12,7 +12,7 @@
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 @@ fn visit_expr(&mut self, expr: &mut P<ast::Expr>) {
});
}
// 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 @@ fn visit_pat(&mut self, pat: &mut P<ast::Pat>) {
}
// 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()

View File

@ -210,8 +210,10 @@ fn visit_block(&mut self, b: &'a ast::Block) {
}
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) {

View File

@ -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