Run buffered lints attached to anon consts

Fixes #84195
This commit is contained in:
Aaron Hill 2021-04-15 11:11:44 -04:00
parent 8aa11816f3
commit 19c9d93ab5
No known key found for this signature in database
GPG Key ID: B4087E510E98B164
3 changed files with 35 additions and 0 deletions

View File

@ -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);
}

View File

@ -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!()] = [];
}

View File

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