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: token -> normalized_token, nonnormalized_token -> token #69384

Merged
merged 2 commits into from
Feb 28, 2020

Conversation

petrochenkov
Copy link
Contributor

So, after #69006, its follow-ups and an attempt to remove Parser::prev_span I came to the conclusion that the unnormalized token and its span is what you want in most cases, so it should be default.

Normalization only makes difference in few cases where we are checking against token::Ident or token::Lifetime specifically.
This PR uses normalized_token for those cases.

Using normalization explicitly means that people writing code should remember about NtIdent and NtLifetime in general. (That is alleviated by the fact that token.ident() and fn parse_ident_* are already written.)
Remembering about NtIdent, was, however, already the case, kind of, because the implicit normalization was performed only for the current/previous token, but not for things like look_ahead.
As a result, most of token classification methods in token.rs already take NtIdent into account (this PR fixes a few pre-existing minor mistakes though).

The next step is removing normalized(_prev)_token entirely and replacing it with token.ident() (mostly) and token.normalize() (occasionally).
I want to make it a separate PR for that and run it though perf.
normalized_token filled on every bump has both a potential to avoid repeated normalization, and to do unnecessary work in advance (it probably doesn't matter anyway, the normalization is very cheap).

r? @Centril

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 22, 2020
@Centril
Copy link
Contributor

Centril commented Feb 23, 2020

r=me with comment considered.

@petrochenkov
Copy link
Contributor Author

@bors r=Centril

@bors
Copy link
Contributor

bors commented Feb 23, 2020

📌 Commit aa1e071deefb5a983bca3f9f0ff57779a5a8e7d1 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 23, 2020
@bors
Copy link
Contributor

bors commented Feb 23, 2020

☔ The latest upstream changes (presumably #69393) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 23, 2020
@petrochenkov
Copy link
Contributor Author

@bors r=Centril

@bors
Copy link
Contributor

bors commented Feb 24, 2020

📌 Commit 91971f8c6768eaee8212495db9d9b9a41788257f 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 24, 2020
@petrochenkov
Copy link
Contributor Author

@bors r-
Noticed a couple of mistakes by auditing edition checks in the parser.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 24, 2020
@petrochenkov
Copy link
Contributor Author

@bors r=Centril

@bors
Copy link
Contributor

bors commented Feb 24, 2020

📌 Commit b2605c1 has been approved by Centril

@bors
Copy link
Contributor

bors commented Feb 24, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 24, 2020
bors added a commit that referenced this pull request Feb 28, 2020
Rollup of 10 pull requests

Successful merges:

 - #68989 (Update RELEASES.md for 1.42.0)
 - #69340 (instantiate_value_path: on `SelfCtor`, avoid unconstrained tyvars)
 - #69384 (parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`)
 - #69452 (typeck: use `Pattern` obligation cause more for better diagnostics)
 - #69481 (use char instead of &str for single char patterns)
 - #69522 (error_derive_forbidden_on_non_adt: be more graceful)
 - #69538 (Stabilize `boxed_slice_try_from`)
 - #69539 (late resolve, visit_fn: bail early if there's no body.)
 - #69541 (Remove unneeded calls to format!())
 - #69547 (remove redundant clones, references to operands, explicit boolean comparisons and filter(x).next() calls.)

Failed merges:

r? @ghost
@bors bors merged commit 3828fa2 into rust-lang:master Feb 28, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 29, 2020
rustc_parse: Tweak the function parameter name check

The function doesn't need a full token, only its edition.

Noticed while implementing rust-lang#69384.
I'm still not sure whether normalized or unnormalized token is a better fit for the edition check here, so  rust-lang#69384 and this PR just keep the status quo behavior.
r? @Centril
JohnTitor added a commit to JohnTitor/rust 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