]> git.lizzy.rs Git - rust.git/commit - src/tools/clippy
Rollup merge of #69384 - petrochenkov:nounnorm, r=Centril
authorMazdak Farrokhzad <twingoow@gmail.com>
Fri, 28 Feb 2020 16:17:26 +0000 (17:17 +0100)
committerGitHub <noreply@github.com>
Fri, 28 Feb 2020 16:17:26 +0000 (17:17 +0100)
commit3828fa2852bf5e622267b24c4eda74e4fa6cb5f9
tree942eb14f5b56c674c718599132032347e61c4d04
parent76fe44928281ae6f1ffe881712e02fb2358a4883
parentb2605c118de31db9d61a9f7d0d158b9bf35f7a4a
Rollup merge of #69384 - petrochenkov:nounnorm, r=Centril

parser: `token` -> `normalized_token`, `nonnormalized_token` -> `token`

So, after https://github.com/rust-lang/rust/pull/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
src/librustc_parse/parser/expr.rs
src/librustc_parse/parser/item.rs
src/librustc_parse/parser/mod.rs
src/libsyntax/token.rs