diff options
| author | Ralf Jung <post@ralfj.de> | 2025-06-28 07:40:14 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-06-28 07:40:14 +0000 |
| commit | 96a70e2e917a2e8e1dc028fcaeacba5b420d8e71 (patch) | |
| tree | ad46d6add78b59ba3d90ffab57c876d237e4ace0 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 03901977c9b88132a478b4dba6ebb8a795140082 (diff) | |
| parent | 35e6def4879ff3b30862d827665ce9da052ed730 (diff) | |
| download | rust-96a70e2e917a2e8e1dc028fcaeacba5b420d8e71.tar.gz rust-96a70e2e917a2e8e1dc028fcaeacba5b420d8e71.zip | |
Merge pull request #4417 from rust-lang/rustup-2025-06-28
Automatic Rustup
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 93c76c47f06..3cedc86dc0d 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -847,7 +847,7 @@ impl<'a> Parser<'a> { self.dcx().emit_err(errors::LifetimeInBorrowExpression { span, lifetime_span: lt_span }); } - /// Parse `mut?` or `raw [ const | mut ]`. + /// Parse `mut?` or `[ raw | pin ] [ const | mut ]`. fn parse_borrow_modifiers(&mut self) -> (ast::BorrowKind, ast::Mutability) { if self.check_keyword(exp!(Raw)) && self.look_ahead(1, Token::is_mutability) { // `raw [ const | mut ]`. @@ -855,6 +855,11 @@ impl<'a> Parser<'a> { assert!(found_raw); let mutability = self.parse_const_or_mut().unwrap(); (ast::BorrowKind::Raw, mutability) + } else if let Some((ast::Pinnedness::Pinned, mutbl)) = self.parse_pin_and_mut() { + // `pin [ const | mut ]`. + // `pin` has been gated in `self.parse_pin_and_mut()` so we don't + // need to gate it here. + (ast::BorrowKind::Pin, mutbl) } else { // `mut?` (ast::BorrowKind::Ref, self.parse_mutability()) @@ -3870,8 +3875,7 @@ impl<'a> Parser<'a> { // Check if a colon exists one ahead. This means we're parsing a fieldname. let is_shorthand = !this.look_ahead(1, |t| t == &token::Colon || t == &token::Eq); // Proactively check whether parsing the field will be incorrect. - let is_wrong = this.token.is_ident() - && !this.token.is_reserved_ident() + let is_wrong = this.token.is_non_reserved_ident() && !this.look_ahead(1, |t| { t == &token::Colon || t == &token::Eq |
