Should tokens passed through macro_rules
be able to join?
#127123
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
A-proc-macro-back-compat
Area: Backwards compatibility hacks for proc macros
C-discussion
Category: Discussion or questions that doesn't represent real issues.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
WG-macros
Working group: Macros
Should this example
emit
1 == 2
and compile successfully?Or, in other words, should the first emitted
=
have theSpacing::Joint
set, 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
.Alone
in the example above because there is a space after the first=
inmac!(= sep =)
.sep
being present in the input but not in the output.$($tt)*
should of course use this option.$a:tt
in the example (or just the$a
part of it).Joint
in the example above because there is no space after$a
in1 $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.The text was updated successfully, but these errors were encountered: