diff options
| author | bors <bors@rust-lang.org> | 2025-04-14 16:45:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-04-14 16:45:11 +0000 |
| commit | 990039ec53d5bffe0ec77391e00f0e5be05924e8 (patch) | |
| tree | 019b3318c00d67290c0178b47edc60fcba59af4b /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 07d3fd1d9b9c1f07475b96a9d168564bf528db68 (diff) | |
| parent | 47e5b18f33550ee3db479748650e93291fdec6eb (diff) | |
| download | rust-990039ec53d5bffe0ec77391e00f0e5be05924e8.tar.gz rust-990039ec53d5bffe0ec77391e00f0e5be05924e8.zip | |
Auto merge of #139814 - matthiaskrgr:rollup-lxkkcz6, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #139127 (Fix up partial res of segment in primitive resolution hack) - #139392 (Detect and provide suggestion for `&raw EXPR`) - #139767 (Visit place in `BackwardIncompatibleDropHint` statement) - #139777 (Remove `define_debug_via_print` for `ExistentialProjection`, use regular structural debug impl) - #139796 (ptr docs: add missing backtics around 'usize') - #139801 (Add myself to mailmap) - #139804 (use `realpath` in `bootstrap.py` when creating build-dir) - #139807 (Improve wording of post-merge report) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 14bc98f66da..df44b3cc23c 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -827,6 +827,18 @@ impl<'a> Parser<'a> { if let Some(lt) = lifetime { self.error_remove_borrow_lifetime(span, lt.ident.span.until(expr.span)); } + + // Add expected tokens if we parsed `&raw` as an expression. + // This will make sure we see "expected `const`, `mut`", and + // guides recovery in case we write `&raw expr`. + if borrow_kind == ast::BorrowKind::Ref + && mutbl == ast::Mutability::Not + && matches!(&expr.kind, ExprKind::Path(None, p) if p.is_ident(kw::Raw)) + { + self.expected_token_types.insert(TokenType::KwMut); + self.expected_token_types.insert(TokenType::KwConst); + } + Ok((span, ExprKind::AddrOf(borrow_kind, mutbl, expr))) } |
