Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
run_early_pass!(self, check_fn, fk, span, id);
self.check_id(id);
ast_visit::walk_fn(self, fk, span);

// Explicitly check for lints associated with 'closure_id', since
// it does not have a corresponding AST node
if let ast_visit::FnKind::Fn(_, _, sig, _, _) = fk {
if let ast::Async::Yes { closure_id, .. } = sig.header.asyncness {
self.check_id(closure_id);
}
}
run_early_pass!(self, check_fn_post, fk, span, id);
}

Expand Down Expand Up @@ -208,6 +216,14 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>

fn visit_expr_post(&mut self, e: &'a ast::Expr) {
run_early_pass!(self, check_expr_post, e);

// Explicitly check for lints associated with 'closure_id', since
// it does not have a corresponding AST node
if let ast::ExprKind::Closure(_, asyncness, ..) = e.kind {
if let ast::Async::Yes { closure_id, .. } = asyncness {
self.check_id(closure_id);
}
}
}

fn visit_generic_arg(&mut self, arg: &'a ast::GenericArg) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// check-pass
// edition:2018
#![warn(semicolon_in_expressions_from_macros)]

#[allow(dead_code)]
Expand All @@ -11,6 +12,11 @@ macro_rules! foo {
}
}

#[allow(semicolon_in_expressions_from_macros)]
async fn bar() {
foo!(first);
}

fn main() {
// This `allow` doesn't work
#[allow(semicolon_in_expressions_from_macros)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: trailing semicolon in macro used in expression position
--> $DIR/semicolon-in-expressions-from-macros.rs:7:13
--> $DIR/semicolon-in-expressions-from-macros.rs:8:13
|
LL | true;
| ^
Expand All @@ -8,7 +8,7 @@ LL | foo!(first)
| ----------- in this macro invocation
|
note: the lint level is defined here
--> $DIR/semicolon-in-expressions-from-macros.rs:2:9
--> $DIR/semicolon-in-expressions-from-macros.rs:3:9
|
LL | #![warn(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -17,7 +17,7 @@ LL | #![warn(semicolon_in_expressions_from_macros)]
= note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: trailing semicolon in macro used in expression position
--> $DIR/semicolon-in-expressions-from-macros.rs:7:13
--> $DIR/semicolon-in-expressions-from-macros.rs:8:13
|
LL | true;
| ^
Expand Down