diff options
| author | Vincenzo Palazzo <vincenzopalazzodev@gmail.com> | 2024-05-31 18:10:30 +0000 |
|---|---|---|
| committer | Vincenzo Palazzo <vincenzopalazzodev@gmail.com> | 2024-06-02 09:42:21 +0200 |
| commit | 36d5fc9a64769be2dc539d90c9dd374ef45d30c6 (patch) | |
| tree | 70b27cefd89f39ecdb743f74ee80047375047c39 /compiler/rustc_parse/src/parser/nonterminal.rs | |
| parent | 06d99cd6947db110d5b8cd44b91852372083d087 (diff) | |
| download | rust-36d5fc9a64769be2dc539d90c9dd374ef45d30c6.tar.gz rust-36d5fc9a64769be2dc539d90c9dd374ef45d30c6.zip | |
Avoid checking the edition as much as possible
Inside #123865, we are adding support for the new semantics for expr2024, but we have noted a performance issue. We realized there is a redundant check for each token regarding an edition. This commit moves the edition check to the end, avoiding some extra checks that can slow down compilation time. Link: https://github.com/rust-lang/rust/pull/123865 Co-Developed-by: @eholk Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Diffstat (limited to 'compiler/rustc_parse/src/parser/nonterminal.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/nonterminal.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index 619c4c63e51..a0b704aeea5 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -47,7 +47,7 @@ impl<'a> Parser<'a> { token.can_begin_expr() // This exception is here for backwards compatibility. && !token.is_keyword(kw::Let) - && (token.span.edition().at_least_rust_2024() || !token.is_keyword(kw::Const)) + && (!token.is_keyword(kw::Const) || token.span.edition().at_least_rust_2024()) } NonterminalKind::Ty => token.can_begin_type(), NonterminalKind::Ident => get_macro_ident(token).is_some(), |
