-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
parser: Remove Parser::prev_span
#69579
Conversation
if self.eat_keyword(kw::Catch) { | ||
let mut error = | ||
self.struct_span_err(self.prev_span, "keyword `catch` cannot follow a `try` block"); | ||
let mut error = self.struct_span_err( | ||
self.prev_token.span, | ||
"keyword `catch` cannot follow a `try` block", | ||
); | ||
error.help("try using `match` on the result of the `try` block instead"); | ||
error.emit(); | ||
Err(error) |
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.
Maybe we should improve recovery here? (Not in this PR)
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.
(cc @estebank)
@@ -568,7 +568,7 @@ impl<'a> Parser<'a> { | |||
&& self.look_ahead(1, |t| t.is_non_raw_ident_where(|i| i.name != kw::As)) | |||
{ | |||
self.bump(); // `default` | |||
Defaultness::Default(self.prev_span) | |||
Defaultness::Default(self.normalized_prev_token.span) |
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 because of the is_non_raw_ident_where
?
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.
No, because default
is an identifier.
It's more important for async
which performs an edition check on the span, but I used normalization for all enum Foo { Yes(Span), No }
keywords for consistency.
} | ||
|
||
/// Parses constness: `const` or nothing. | ||
fn parse_constness(&mut self) -> Const { | ||
if self.eat_keyword(kw::Const) { Const::Yes(self.prev_span) } else { Const::No } | ||
if self.eat_keyword(kw::Const) { | ||
Const::Yes(self.normalized_prev_token.span) |
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.
And this is also because of eat_keyword
dealing with identifiers? Although check_keyword
doesn't seem to be using normalized_token
... but normalization does happens automatically in bump_with
.
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.
Same answer as in #69579 (comment), const
is an identifier.
eat_keyword
works correctly because it uses token.ident()
internally which uses normalization.
@bors r+ |
📌 Commit 7de9a72 has been approved by |
Rollup of 7 pull requests Successful merges: - #69397 (bootstrap: Remove commit hash from LLVM version suffix to avoid rebuilds) - #69549 (Improve MinGW detection when cross compiling ) - #69562 (Don't `bug` when taking discriminant of generator during dataflow) - #69579 (parser: Remove `Parser::prev_span`) - #69580 (use .copied() instead of .map(|x| *x) on iterators) - #69583 (Do not ICE on invalid type node after parse recovery) - #69605 (Use `opt_def_id()` over `def_id()`) Failed merges: r? @ghost
rustc_parse: Remove `Parser::normalized(_prev)_token` Perform the "normalization" (renamed to "uninterpolation") on the fly when necessary. The final part of rust-lang#69579 rust-lang#69384 rust-lang#69376 rust-lang#69211 rust-lang#69034 rust-lang#69006. r? @Centril
Follow-up to #69384.
r? @Centril