Repository navigation
Description
This is a tracking issue for MCP rust-lang/lang-team#70
What is this issue?
If you're a crate author who's been linked here, this issue tracks emitting a hard error when a trailing semicolon occurs in a macro used in expression position. See rust-lang/lang-team#70 for some background about the issue.
In the future, code like this may stop compiling:
macro_rules! foo {
() => {
true;
}
}
fn main() {
let val = match true {
true => false,
_ => foo!()
};
}In the above code snippet, foo!() is invoked in expression position (in this case, a macro arm). However, foo!() expands to the token stream true;, which is not a valid expression due to the presence of a trailing semicolon.
To make the behavior of macro expansion more consistent, we plan to turn this into a hard error at some point in the future.
Fixing issues in your crate is usually as simple as removing the trailing semicolon from the macro definition.
Currently, the associated lint (semicolon_in_expressions_from_macros) is set to allow-by-default. As time goes on, we may increase this to warn-by-default.
About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
- Implement the lint: Add
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSlint #79819 - Do a Crater run to determine the full extent of the impact ([EXPERIMENT] Error on trailing semicolons in macro expressions #81477)
- Fix
lint_node_idso that we can apply#[allow]close to a macro call site (Compute a betterlint_node_idduring expansion #87146) - When Don't insert semicolons inside of a
macro_rules!arm body rustfmt#4507 makes it way into a stable release, make the lint warn-by-default - Mark the lint for inclusion in the cargo future-incompat-report (see Tracking Issue for cargo report future-incompat #71249) (Add
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSto future-incompat report #103418) - Switch the lint to deny-by-default
- Consider making the lint a hard error over an edition boundary
Unresolved Questions
Implementation history
- Lint implemented in Add
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSlint #79819 - Made warn-by-default in Make
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSwarn by default #87385 - Added to future-incompat report in Add
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSto future-incompat report #103418 - Made deny-by-default in Upgrade semicolon_in_expressions_from_macros from warn to deny #144369
Activity
Rollup merge of rust-lang#79819 - Aaron1011:feature/macro-trailing-se…
Rollup merge of rust-lang#79819 - Aaron1011:feature/macro-trailing-se…
Remove trailing semicolon from err! macro
Remove trailing semicolon from fail! macro
222 remaining items
Fix new nightly lint: rust-lang/rust#79813
Remove trailing semicolons from macro bodies (#940)
fix(common_utils): drop two trailing semicolons that will become hard…
dep[cfg_aliases]: Bump to 0.2.2
Fix new nightly lint: rust-lang/rust#79813
Fix assert! and cover! expansions in expression contexts (model-check…
chore: end miette bail! calls with a semicolon so clippy passes on Ru…
Update the version of `rexpect` to use nix v0.31
breaking: remove trailing semi from bail!()
Remove trailing semicolon in trace_err_chain! macro (#6515)
Remove trailing semicolon in trace_err_chain! macro (#6515) (#6530)
fix trailing semicolon in macro (#4884)
fix: clear new warnings on rustc v1.99.0 (rust-lang/rust#79813)
Remove trailing semicolons in all macro definitions.
Remove semicolon from macro bodies to fix lint warning (#1)