Uh oh!
There was an error while loading. Please reload this page.
Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS lint - #79819
Conversation
rust-highfive
commented
Dec 8, 2020
(rust-highfive has picked a reviewer for you, use r? to override) |
f8734e0 to
c138cfbComparec138cfb to
1d8d56eCompareAaron1011
commented
Dec 8, 2020
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. |
Aaron1011
commented
Dec 8, 2020
Unfortunately, inert attributes on macro invocations (e.g. |
Aaron1011
commented
Dec 8, 2020
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. |
petrochenkov
commented
Dec 11, 2020
petrochenkov
commented
Dec 12, 2020
I agree that the We have a method |
Dylan-DPC-zz
commented
Jan 13, 2021
@bors try |
bors
commented
Jan 13, 2021
⌛ 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
2603555CompareAaron1011
commented
Jan 27, 2021
@petrochenkov I've updated the PR to use |
This comment has been minimized.
This comment has been minimized.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
petrochenkov
commented
Jan 27, 2021
The comment on |
96c5f6b to
4867fadComparecc 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
f902551CompareAaron1011
commented
Jan 28, 2021
@bors r=petrochenkov |
bors
commented
Jan 28, 2021
📌 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.