-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Should tokens passed through macro_rules be able to join? #127123
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, ..)A-proc-macro-back-compatArea: Backwards compatibility hacks for proc macrosArea: Backwards compatibility hacks for proc macrosC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamWG-macrosWorking group: MacrosWorking group: Macros
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, ..)A-proc-macro-back-compatArea: Backwards compatibility hacks for proc macrosArea: Backwards compatibility hacks for proc macrosC-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language teamWG-macrosWorking group: MacrosWorking group: Macros
Type
Fields
Give feedbackNo fields configured for issues without a type.
Should this example
emit
1 == 2and compile successfully?Or, in other words, should the first emitted
=have theSpacing::Jointset, if the output is processed by a proc macro?We need some well-defined rule for setting spacing for tokens produced from macro variables.
Possible alternatives:
Joint.Alone.Alonein the example above because there is a space after the first=inmac!(= sep =).sepbeing present in the input but not in the output.$($tt)*should of course use this option.$a:ttin the example (or just the$apart of it).Jointin the example above because there is no space after$ain1 $a$b 2.Right now the spacing is emitted inconsistently, sometimes it follows the rule
2., sometimes3..Adopting any consistent rule may cause breakage (@nnethercote may remember which exactly) and needs to go through crater.
5.first, because it gives macro author freedom to control and change spacing as they want, unlike rule2.that prevents joining entirely.2.instead due to backward compatibility issues. It would be less flexible, but macro variables creating a "barrier" for joining is also a reasonable enough model.