diff options
| author | Frank King <frankking1729@gmail.com> | 2025-01-19 22:01:11 +0800 |
|---|---|---|
| committer | Frank King <frankking1729@gmail.com> | 2025-06-15 10:21:29 +0800 |
| commit | e627f88f88de85cc52ff1c99a076909084806c98 (patch) | |
| tree | 0f53bd1e6bef6c79ada367f0a6ca8c7ac6eb2f93 /compiler/rustc_parse/src/parser/expr.rs | |
| parent | 49a8ba06848fa8f282fe9055b4178350970bb0ce (diff) | |
| download | rust-e627f88f88de85cc52ff1c99a076909084806c98.tar.gz rust-e627f88f88de85cc52ff1c99a076909084806c98.zip | |
Implement pinned borrows, part of `pin_ergonomics`
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 93489aa8ee9..b64b50cf187 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()) |
