-
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: token
-> normalized_token
, nonnormalized_token
-> token
#69384
Conversation
r=me with comment considered. |
8a5d59e
to
aa1e071
Compare
@bors r=Centril |
📌 Commit aa1e071deefb5a983bca3f9f0ff57779a5a8e7d1 has been approved by |
☔ The latest upstream changes (presumably #69393) made this pull request unmergeable. Please resolve the merge conflicts. |
aa1e071
to
91971f8
Compare
@bors r=Centril |
📌 Commit 91971f8c6768eaee8212495db9d9b9a41788257f has been approved by |
@bors r- |
91971f8
to
b2605c1
Compare
@bors r=Centril |
📌 Commit b2605c1 has been approved by |
🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened |
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
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
parser: Remove `Parser::prev_span` Follow-up to rust-lang#69384. r? @Centril
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
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
ortoken::Lifetime
specifically.This PR uses
normalized_token
for those cases.Using normalization explicitly means that people writing code should remember about
NtIdent
andNtLifetime
in general. (That is alleviated by the fact thattoken.ident()
andfn 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 likelook_ahead
.As a result, most of token classification methods in
token.rs
already takeNtIdent
into account (this PR fixes a few pre-existing minor mistakes though).The next step is removing
normalized(_prev)_token
entirely and replacing it withtoken.ident()
(mostly) andtoken.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