diff options
| author | bors <bors@rust-lang.org> | 2024-08-01 02:26:32 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-01 02:26:32 +0000 |
| commit | e485266c673a1bdd7f112700b7a3ec4235816e7d (patch) | |
| tree | f73fe55c545c5bff8e23bc212469a51c9ca333ff /compiler/rustc_parse/src/parser | |
| parent | 71b211609605590423a68ba3f503e53404d4fdb4 (diff) | |
| parent | 7060a2f356ecb3bbe53950999ce08ab76e36b4bb (diff) | |
| download | rust-e485266c673a1bdd7f112700b7a3ec4235816e7d.tar.gz rust-e485266c673a1bdd7f112700b7a3ec4235816e7d.zip | |
Auto merge of #128461 - matthiaskrgr:rollup-3dpp11g, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #123813 (Add `REDUNDANT_IMPORTS` lint for new redundant import detection) - #126697 ([RFC] mbe: consider the `_` in 2024 an expression) - #127159 (match lowering: Hide `Candidate` from outside the lowering algorithm) - #128244 (Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks) - #128431 (Add myself as VxWorks target maintainer for reference) - #128438 (Add special-case for [T, 0] in dropck_outlives) - #128457 (Fix docs for OnceLock::get_mut_or_init) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/nonterminal.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/nonterminal.rs b/compiler/rustc_parse/src/parser/nonterminal.rs index bd9d96ba573..999f6f0eeb0 100644 --- a/compiler/rustc_parse/src/parser/nonterminal.rs +++ b/compiler/rustc_parse/src/parser/nonterminal.rs @@ -39,6 +39,7 @@ impl<'a> Parser<'a> { } match kind { + // `expr_2021` and earlier NonterminalKind::Expr(Expr2021 { .. }) => { token.can_begin_expr() // This exception is here for backwards compatibility. @@ -46,8 +47,16 @@ impl<'a> Parser<'a> { // This exception is here for backwards compatibility. && !token.is_keyword(kw::Const) } + // Current edition expressions NonterminalKind::Expr(Expr) => { - token.can_begin_expr() + // In Edition 2024, `_` is considered an expression, so we + // need to allow it here because `token.can_begin_expr()` does + // not consider `_` to be an expression. + // + // Because `can_begin_expr` is used elsewhere, we need to reduce + // the scope of where the `_` is considered an expression to + // just macro parsing code. + (token.can_begin_expr() || token.is_keyword(kw::Underscore)) // This exception is here for backwards compatibility. && !token.is_keyword(kw::Let) } |
