Skip to content

Commit a6416d8

Browse files
committed
Auto merge of rust-lang#125828 - vincenzopalazzo:macros/performance-regression, r=fmease
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. While talking with `@eholk,` 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. However, we should keep this issue under observation because we may want to improve the edition check if we are unable to significantly improve compiler performance. r? ghost
2 parents eda9d7f + 36d5fc9 commit a6416d8

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)