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.
Maybe we should improve recovery here? (Not in this PR)
| { | ||
| self.bump(); // `default` | ||
| Defaultness::Default(self.prev_span) | ||
| Defaultness::Default(self.normalized_prev_token.span) |
There was a problem hiding this comment.
This is because of the is_non_raw_ident_where?
There was a problem hiding this comment.
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.
| 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.
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.
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