-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix some grammar inconsistencies for the '..' range notation. #21374
Conversation
r? @nick29581 (rust_highfive has picked a reviewer for you, use r? to override) |
Grammar changes: * allow 'for _ in 1..i {}' (fixes rust-lang#20241) * allow 'for _ in 1.. {}' as infinite loop * prevent use of range notation in contexts where only operators of high precedence are expected (fixes rust-lang#20811) Parser code cleanup: * remove RESTRICTION_NO_DOTS * make AS_PREC const and follow naming convention * make min_prec inclusive
7fb1be2
to
db013f9
Compare
Rebased onto the big |
@dgrunwald ok reading this now. On the face of it, it looks much nicer than the previous patch. I haven't had time to play with it yet, but I take it that this means that |
I think I am happy with this version, all things considered. A good compromise. |
looks fine to me too. |
⌛ Testing commit db013f9 with merge 90224cf... |
💔 Test failed - auto-mac-64-nopt-t |
@bors: retry |
⌛ Testing commit db013f9 with merge e9285f9... |
This PR is intended as alternative to #20958. It fixes the same grammar inconsistencies, but does not increase the operator precedence of `..`, leaving it at the same level as the assignment operator. For previous discussion, see #20811 and #20958. Grammar changes: * allow `for _ in 1..i {}` (fixes #20241) * allow `for _ in 1.. {}` as infinite loop * prevent use of range notation in contexts where only operators of high precedence are expected (fixes #20811) Parser code cleanup: * remove `RESTRICTION_NO_DOTS` * make `AS_PREC` const and follow naming convention * make `min_prec` inclusive r? nikomatsakis
Note: Do not merge until we get a newer snapshot that includes #21374 There was some type inference fallout (see 4th commit) because type inference with `a..b` is not as good as with `range(a, b)` (see #21672). r? @alexcrichton
Note: Do not merge until we get a newer snapshot that includes #21374 There was some type inference fallout (see 4th commit) because type inference with `a..b` is not as good as with `range(a, b)` (see #21672). r? @alexcrichton
This PR is intended as alternative to #20958. It fixes the same grammar inconsistencies, but does not increase the operator precedence of
..
, leaving it at the same level as the assignment operator.For previous discussion, see #20811 and #20958.
Grammar changes:
for _ in 1..i {}
(fixes range syntax doesn't work with non-literal endpoints in for statements #20241)for _ in 1.. {}
as infinite loopParser code cleanup:
RESTRICTION_NO_DOTS
AS_PREC
const and follow naming conventionmin_prec
inclusiver? nikomatsakis