Conversation
|
@matklad you said the adjustment would need to be in In an example like It's unfortunate that subslice patterns can be parsed outside of slice patterns. I think I can fix that by adding a bool flag to |
| atom_pat(p, recovery_set); | ||
| m.complete(p, RANGE_PAT); | ||
| if subslice_patterns && dots == T![..] && !p.at_ts(PATTERN_FIRST) { | ||
| m.complete(p, SUBSLICE_PAT); |
There was a problem hiding this comment.
Hm, I think this is still not exactly what we want, as it'll match [1..], which is wrong: we need to enfroce that lhs is identifier.
I think the best solution would be to inline pat_list into slice_pat and handle a.. specially, simliar to ..:
T![..] => p.bump(),
There was a problem hiding this comment.
That is, special casing should happen around here: https://github.com/rust-analyzer/rust-analyzer/blob/5b19825e376b67aabbe8d5b163bf69b1acd92f04/crates/ra_parser/src/grammar/patterns.rs#L241
There was a problem hiding this comment.
Ah, yeah, I see pat_list is already inlined! So, we only need to pull haling of .. out of pattern_with_subslice_patterns into the while !p.at(EOF) && !p.at(T![']']) { loop
0b873da to
c4cbadf
Compare
|
OK, this commit copies from rustc does actually parse |
|
I think this won't parse macro patterns followed by |
|
Wow, looks like I don't really understand what this syntax means in the first place... I would expect that macros wouldn't be allowed to the left of |
|
Ok, so after reading through several RFC, it looks like Chasing unstable features is annoying :) |
The syntax |
|
UPDATE: The PR rust-lang/rust#62550 has been merged. |
|
closing due to inactivity! |
This attempt detects subslice patterns in the same place as range patterns;
when the right hand side of a
..in a potential range definitely isn't a pattern,the parser stops and emits a
SUBSLICE_PATinstead.cc #1479