Skip to content

Commit 36d5fc9

Browse files
Avoid checking the edition as much as possible
Inside rust-lang#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: rust-lang#123865 Co-Developed-by: @eholk Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
1 parent 06d99cd commit 36d5fc9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

compiler/rustc_parse/src/parser/nonterminal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a> Parser<'a> {
4747
token.can_begin_expr()
4848
// This exception is here for backwards compatibility.
4949
&& !token.is_keyword(kw::Let)
50-
&& (token.span.edition().at_least_rust_2024() || !token.is_keyword(kw::Const))
50+
&& (!token.is_keyword(kw::Const) || token.span.edition().at_least_rust_2024())
5151
}
5252
NonterminalKind::Ty => token.can_begin_type(),
5353
NonterminalKind::Ident => get_macro_ident(token).is_some(),

0 commit comments

Comments
 (0)