Skip to content
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

Merged
merged 2 commits into from
Mar 1, 2020
Merged

Conversation

petrochenkov
Copy link
Contributor

Follow-up to #69384.
r? @Centril

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 29, 2020
Comment on lines 1682 to 1689
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)
Copy link
Contributor

@Centril Centril Feb 29, 2020

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)

Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

@Centril Centril Feb 29, 2020

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.

Copy link
Contributor Author

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.

@Centril
Copy link
Contributor

Centril commented Feb 29, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Feb 29, 2020

📌 Commit 7de9a72 has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 29, 2020
bors added a commit that referenced this pull request Mar 1, 2020
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
@bors bors merged commit 4439bb0 into rust-lang:master Mar 1, 2020
JohnTitor added a commit to JohnTitor/rust-clippy that referenced this pull request Mar 1, 2020
bors added a commit that referenced this pull request Mar 8, 2020
rustc_parse: Remove `Parser::normalized(_prev)_token`

Perform the "normalization" (renamed to "uninterpolation") on the fly when necessary.

The final part of #69579 #69384 #69376 #69211 #69034 #69006.
r? @Centril
Centril added a commit to Centril/rust that referenced this pull request Mar 9, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants