Allow range-to-inclusive macro patterns - #158836
chenyukang wants to merge 1 commit into
Conversation
|
r? @folkertdev rustbot has assigned @folkertdev. Use Why was this reviewer chosen?The reviewer was selected based on:
|
c413d1d to
72c1568
Compare
This comment has been minimized.
This comment has been minimized.
|
r? @nnethercote Looks fine but it's macro parsing to there might be something subtle I'm missing |
There was a problem hiding this comment.
I think the "only used for diagnostics" is not true; can_begin_pattern is used in both nonterminal_may_begin_with and parse_pat_with_range_pat which affect code parsing.
There was a problem hiding this comment.
this was added only for diagnostic.
the parse_pat_with_range_pat invocation is also emitting error:
rust/compiler/rustc_parse/src/parser/pat.rs
Lines 734 to 744 in bcd9ae8
the nonterminal_may_begin_with is indeed expand its usage, with a comment here:
https://github.com/rust-lang/rust/pull/120221/changes#r1669391427
and
#120221 (comment)
|
The change you've made is the obvious fix, but I'm uncertain about whether we can just accept the PR, or if we need some extra verification (e.g. crater run, or lang team involvement). @petrochenkov, what do you think? |
|
Any changes to I probably wouldn't bother running crater for this specific change, unless it's rolled up with something else or as a part of beta run. |
72c1568 to
067ec56
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
yes, this seems is a break change, here is an example where the selected macro arm changes: macro_rules! select {
($p:pat) => { "pattern" };
($($tokens:tt)*) => { "fallback" };
}
fn main() {
println!("{}", select!(..=0));
}currently this prints but the Reference already specifies that seems this is a difference between our current code with reference. |
Fixes #120737