Skip to content

Commit

Permalink
Auto merge of #84222 - Aaron1011:fix/anon-const-lint, r=lcnr
Browse files Browse the repository at this point in the history
Run buffered lints attached to anon consts

Fixes #84195
  • Loading branch information
bors committed Apr 15, 2021
2 parents 2962e7c + 19c9d93 commit 60158f4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/early.rs
Expand Up @@ -109,6 +109,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>

fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
run_early_pass!(self, check_anon_const, c);
self.check_id(c.id);
ast_visit::walk_anon_const(self, c);
}

Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/macros/issue-84195-lint-anon-const.rs
@@ -0,0 +1,14 @@
// Regression test for issue #84195
// Checks that we properly fire lints that occur inside
// anon consts.

#![deny(semicolon_in_expressions_from_macros)]

macro_rules! len {
() => { 0; }; //~ ERROR trailing semicolon
//~| WARN this was previously accepted
}

fn main() {
let val: [u8; len!()] = [];
}
20 changes: 20 additions & 0 deletions src/test/ui/macros/issue-84195-lint-anon-const.stderr
@@ -0,0 +1,20 @@
error: trailing semicolon in macro used in expression position
--> $DIR/issue-84195-lint-anon-const.rs:8:14
|
LL | () => { 0; };
| ^
...
LL | let val: [u8; len!()] = [];
| ------ in this macro invocation
|
note: the lint level is defined here
--> $DIR/issue-84195-lint-anon-const.rs:5:9
|
LL | #![deny(semicolon_in_expressions_from_macros)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

0 comments on commit 60158f4

Please sign in to comment.