-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macro future proofing: extend analysis to detect unfortunate interaction across arms #1464
Comments
cc #550 |
So from the previous issue, it seems the goal is to look at these two macro arms ($e:expr) => { ... }
($i:ident : $t:ty => { ... } and detect that the same input could be valid for both arms (assuming We have to be careful though, because macro evaluation is already dependent, and usefully so, on the order of the arms, for example this pattern: (A ...) => { /* case A */ }
(B ...) => { /* case B */ }
($i:ident ...) => { /* other */ } |
Also, are there ideas on how to do the actual ambiguity checking? Not sure if we know what class of parsers |
I haven't put much thought into it, but I am willing to use a conservative analysis that just emits a lint style warning to the macro author. (And never make it an error by default in rustc) (Also, another potential option that has been suggested: expand the macro input matching system so that the expander can "back out" of one arm and try the next. (Ie it becomes a backtracking parser) I am not saying the latter is my preferred solution, but it will be good for us to consider all options when we tackle this problem. ) |
Backtracking would definitely be the preferred solution. Without it, for example, there's no way to parse generic parameters in |
cc #1384 |
spawned off of rust-lang/rust#30531 (comment)
(transcribed relevant material from that comment below.)
The text was updated successfully, but these errors were encountered: