-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Handle $_ in mbe #6929
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
Handle $_ in mbe #6929
Conversation
|
I'm pretty sure this isn't the right solution, though... |
3171d61 to
3e17346
Compare
| fn expand_var(ctx: &mut ExpandCtx, v: &SmolStr) -> ExpandResult<Fragment> { | ||
| fn expand_var(ctx: &mut ExpandCtx, v: Option<&SmolStr>) -> ExpandResult<Fragment> { | ||
| let underscore = SmolStr::new_inline("_"); | ||
| let v = v.unwrap_or(&underscore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all awkward because name: &'a SmolStr so we can't make a new one when needed.
|
And apparently |
Yeah, I am pretty sure we didn't handle underscore as special case in mbe. So let me check what's happened in this week end? |
|
Oh, I understand why now. We treat |
|
If we have to make it to punct for parser, I recommend the following changes: Change to result.push(if k.is_punct() && k != UNDERSCORE {and Add: IDENT => make_leaf!(Ident),
UNDERSCORE => make_leaf!(Ident), // <---
k if k.is_keyword() => make_leaf!(Ident), |
3e17346 to
75a26f6
Compare
|
Thanks for the pointers, that doesn't seem to break anything else. |
|
LGTM, bors r+ |
|
bors r+ |
7059: Special case $_ in meta var instead of treat it as ident in mbe r=lnicola a=edwin0cheng In #6929, we treat '_' as an ident but rustc is only allow it in some special places (e.g. meta var in mbe , type, pat etc). This PR rollback that and we only make '$_' works in meta var matching. Fixes #7056 Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
Fixes #6926