Skip to content

Run buffered lints attached to anon consts #84222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2021
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
1 change: 1 addition & 0 deletions compiler/rustc_lint/src/early.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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