Skip to content

Commit 60158f4

Browse files
committed
Auto merge of #84222 - Aaron1011:fix/anon-const-lint, r=lcnr
Run buffered lints attached to anon consts Fixes #84195
2 parents 2962e7c + 19c9d93 commit 60158f4

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

compiler/rustc_lint/src/early.rs

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ impl<'a, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a, T>
109109

110110
fn visit_anon_const(&mut self, c: &'a ast::AnonConst) {
111111
run_early_pass!(self, check_anon_const, c);
112+
self.check_id(c.id);
112113
ast_visit::walk_anon_const(self, c);
113114
}
114115

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Regression test for issue #84195
2+
// Checks that we properly fire lints that occur inside
3+
// anon consts.
4+
5+
#![deny(semicolon_in_expressions_from_macros)]
6+
7+
macro_rules! len {
8+
() => { 0; }; //~ ERROR trailing semicolon
9+
//~| WARN this was previously accepted
10+
}
11+
12+
fn main() {
13+
let val: [u8; len!()] = [];
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error: trailing semicolon in macro used in expression position
2+
--> $DIR/issue-84195-lint-anon-const.rs:8:14
3+
|
4+
LL | () => { 0; };
5+
| ^
6+
...
7+
LL | let val: [u8; len!()] = [];
8+
| ------ in this macro invocation
9+
|
10+
note: the lint level is defined here
11+
--> $DIR/issue-84195-lint-anon-const.rs:5:9
12+
|
13+
LL | #![deny(semicolon_in_expressions_from_macros)]
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
15+
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
16+
= note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
17+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
18+
19+
error: aborting due to previous error
20+

0 commit comments

Comments
 (0)