-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS
lint
#79819
Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS
lint
#79819
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
f8734e0
to
c138cfb
Compare
c138cfb
to
1d8d56e
Compare
This becomes tricky when the macro is defined in a different crate. I think we need to instead take the lint level from the macro call site - otherwise, the warning becomes unsurpressable in downstream code. |
Unfortunately, inert attributes on macro invocations (e.g. |
Additionally, linting is currently done after HIR lowering, so the macro call doesn't even exist by the time we would be ready to emit the lint. Implementing this will require some further thought. |
I agree that the We have a method |
@bors try |
⌛ Trying commit 1d8d56e95636056cf085c02decd7a386264310d3 with merge 50473808b4098f3d96d962b3940d38962305e408... |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1d8d56e
to
2603555
Compare
@petrochenkov I've updated the PR to use |
This comment has been minimized.
This comment has been minimized.
The comment on |
96c5f6b
to
4867fad
Compare
cc rust-lang#79813 This PR adds an allow-by-default future-compatibility lint `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS`. It fires when a trailing semicolon in a macro body is ignored due to the macro being used in expression position: ```rust macro_rules! foo { () => { true; // WARN } } fn main() { let val = match true { true => false, _ => foo!() }; } ``` The lint takes its level from the macro call site, and can be allowed for a particular macro by adding `#[allow(semicolon_in_expressions_from_macros)]`. The lint is set to warn for all internal rustc crates (when being built by a stage1 compiler). After the next beta bump, we can enable the lint for the bootstrap compiler as well.
4867fad
to
f902551
Compare
@bors r=petrochenkov |
📌 Commit f902551 has been approved by |
…micolon, r=petrochenkov Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint cc rust-lang#79813 This PR adds an allow-by-default future-compatibility lint `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS`. It fires when a trailing semicolon in a macro body is ignored due to the macro being used in expression position: ```rust macro_rules! foo { () => { true; // WARN } } fn main() { let val = match true { true => false, _ => foo!() }; } ``` The lint takes its level from the macro call site, and can be allowed for a particular macro by adding `#[allow(macro_trailing_semicolon)]`. The lint is set to warn for all internal rustc crates (when being built by a stage1 compiler). After the next beta bump, we can enable the lint for the bootstrap compiler as well.
Rollup of 10 pull requests Successful merges: - rust-lang#79570 (rustc: Stabilize `-Zrun-dsymutil` as `-Csplit-debuginfo`) - rust-lang#79819 (Add `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint) - rust-lang#79991 (rustdoc: Render HRTB correctly for bare functions) - rust-lang#80215 (Use -target when linking binaries for Mac Catalyst) - rust-lang#81158 (Point to span of upvar making closure FnMut) - rust-lang#81176 (Improve safety of `LateContext::qpath_res`) - rust-lang#81287 (Split rustdoc JSON types into separately versioned crate) - rust-lang#81306 (Fuse inner iterator in FlattenCompat and improve related tests) - rust-lang#81333 (clean up some const error reporting around promoteds) - rust-lang#81459 (Fix rustdoc text selection for page titles) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Opening to gather data about the impact of changing the lint level of rust-lang#79819
cc #79813
This PR adds an allow-by-default future-compatibility lint
SEMICOLON_IN_EXPRESSIONS_FROM_MACROS
. It fires when a trailing semicolon in amacro body is ignored due to the macro being used in expression
position:
The lint takes its level from the macro call site, and
can be allowed for a particular macro by adding
#[allow(macro_trailing_semicolon)]
.The lint is set to warn for all internal rustc crates (when being built
by a stage1 compiler). After the next beta bump, we can enable
the lint for the bootstrap compiler as well.