-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Tracking Issue for denying trailing semicolons in expression macro bodies #79813
Copy link
Copy link
Open
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-needs-to-bakeStatus: The implementation is "complete" but it needs time to bake.Status: The implementation is "complete" but it needs time to bake.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-needs-to-bakeStatus: The implementation is "complete" but it needs time to bake.Status: The implementation is "complete" but it needs time to bake.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
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:
In the above code snippet,
foo!()is invoked in expression position (in this case, a macro arm). However,foo!()expands to the token streamtrue;, 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
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSlint #79819lint_node_idso that we can apply#[allow]close to a macro call site (Compute a betterlint_node_idduring expansion #87146)macro_rules!arm body rustfmt#4507 makes it way into a stable release, make the lint warn-by-defaultSEMICOLON_IN_EXPRESSIONS_FROM_MACROSto future-incompat report #103418)Unresolved Questions
Implementation history
SEMICOLON_IN_EXPRESSIONS_FROM_MACROSlint #79819SEMICOLON_IN_EXPRESSIONS_FROM_MACROSwarn by default #87385SEMICOLON_IN_EXPRESSIONS_FROM_MACROSto future-incompat report #103418