You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
macros sometimes allow expr followed by ident #44975
You can use a repetition to get around the future proofer.
macro_rules! bad {($e:expr $i:ident) => {}//~ERROR}macro_rules! sneaky {($($i:ident $e:expr)*) => {}// no error}fnmain(){sneaky!(a b c d);}
I feel that both of these should be accepted, or neither. BTW, I am using the equivalent of sneaky! in brainmunch (found this while preparing my RustFest talk).
Fixing this by disallowing both macros would require cratering.
The danger here is that contextual keywords become impossible. In particular, consider if we added await f as an expression, which would work with bad! today but fail tomorrow.
I'm afraid fixing this is going to be problematic, because even we are using this "feature" in rustc. I'll post a PR with the fix (including changing our mis-uses), but will expect there to be breakage. If that is the case after a crater run, should we still include the fix as a warning?
Wow, that's a lot of fallout in the PR! IMO yes, assuming crater shows
nonzero breakage, add a warning at the definition site (callers too?) for
macros 1.0 and fix it in macros 2.0.
@durka It'd be nice to do, but I'm tempted at leaving devs to deal with the fallout after changing the signature by following the errors they'll get then instead of trying to preempt them, as extending the diagnostic to the callers would be a bigger PR, I fear.
Activity
aturon commentedon Oct 19, 2017
cc @pnkfelix
nikomatsakis commentedon Oct 19, 2017
The danger here is that contextual keywords become impossible. In particular, consider if we added
await fas an expression, which would work withbad!today but fail tomorrow.joshtriplett commentedon Oct 19, 2017
One possibility would be to leave this alone and fix it in macros 2.0. The other would be a crater run and evaluation for a fix.
nikomatsakis commentedon Oct 19, 2017
Some possible routes:
bad!, for the reasons given above.nikomatsakis commentedon Oct 19, 2017
triage: P-medium
nikomatsakis commentedon Oct 19, 2017
I feel like we should at least try the fix -- though it may be hard to ascertain the impact entirely.
durka commentedon Oct 25, 2017
@nikomatsakis do you have any idea how to fix it?
estebank commentedon Oct 26, 2018
I'm afraid fixing this is going to be problematic, because even we are using this "feature" in rustc. I'll post a PR with the fix (including changing our mis-uses), but will expect there to be breakage. If that is the case after a crater run, should we still include the fix as a warning?
durka commentedon Oct 26, 2018
estebank commentedon Oct 26, 2018
@durka It'd be nice to do, but I'm tempted at leaving devs to deal with the fallout after changing the signature by following the errors they'll get then instead of trying to preempt them, as extending the diagnostic to the callers would be a bigger PR, I fear.
Auto merge of #55373 - estebank:macro-rep, r=<try>
Auto merge of #55373 - estebank:macro-rep, r=<try>
Auto merge of #55373 - estebank:macro-rep, r=<try>