-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Allow .. to be parsed as let initializer #105701
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,7 +180,7 @@ impl<'a> Parser<'a> { | |
| LhsExpr::AttributesParsed(attrs) => Some(attrs), | ||
| _ => None, | ||
| }; | ||
| if [token::DotDot, token::DotDotDot, token::DotDotEq].contains(&self.token.kind) { | ||
| if self.token.is_range_seperator() { | ||
| return self.parse_prefix_range_expr(attrs); | ||
| } else { | ||
| self.parse_prefix_expr(attrs)? | ||
|
|
@@ -512,7 +512,7 @@ impl<'a> Parser<'a> { | |
| } | ||
|
|
||
| debug_assert!( | ||
| [token::DotDot, token::DotDotDot, token::DotDotEq].contains(&self.token.kind), | ||
| self.token.is_range_seperator(), | ||
| "parse_prefix_range_expr: token {:?} is not DotDot/DotDotEq", | ||
| self.token | ||
| ); | ||
|
|
@@ -896,7 +896,11 @@ impl<'a> Parser<'a> { | |
| let has_lifetime = self.token.is_lifetime() && self.look_ahead(1, |t| t != &token::Colon); | ||
| let lifetime = has_lifetime.then(|| self.expect_lifetime()); // For recovery, see below. | ||
| let (borrow_kind, mutbl) = self.parse_borrow_modifiers(lo); | ||
| let expr = self.parse_prefix_expr(None); | ||
| let expr = if self.token.is_range_seperator() { | ||
| self.parse_prefix_range_expr(None) | ||
| } else { | ||
| self.parse_prefix_expr(None) | ||
| }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My immediate expectation would be that I've not looked at this code much, but the reason it might matter is for other operator precedence reasons; e.g. what's the correct result of parsing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this separation of prefix range parsing from other prefix expr parsing is done to prevent expressions such as |
||
| let (hi, expr) = self.interpolated_or_expr_span(expr)?; | ||
| let span = lo.to(hi); | ||
| if let Some(lt) = lifetime { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // run-pass | ||
|
RedDocMD marked this conversation as resolved.
Outdated
|
||
|
|
||
| fn main() { | ||
| let _a = ..; | ||
| let _b = ..=10; | ||
| let _c = &..; | ||
| let _d = &..=10; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.