diff options
| author | Lieselotte <52315535+she3py@users.noreply.github.com> | 2024-09-18 20:38:43 +0200 |
|---|---|---|
| committer | Lieselotte <52315535+she3py@users.noreply.github.com> | 2024-09-18 20:38:43 +0200 |
| commit | db09345ef6e7f39110704e6196bb239d8f10fc27 (patch) | |
| tree | a0374ff643b776d21bb32c07aa4cb88631c4d2b5 /compiler/rustc_parse/src/parser/stmt.rs | |
| parent | c2047219b59ac7830c4315653858f28cf0d57b9d (diff) | |
| download | rust-db09345ef6e7f39110704e6196bb239d8f10fc27.tar.gz rust-db09345ef6e7f39110704e6196bb239d8f10fc27.zip | |
Add suggestions for expressions in patterns
Diffstat (limited to 'compiler/rustc_parse/src/parser/stmt.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index 26ad39e06cd..92fba89d28a 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -29,6 +29,9 @@ use crate::{errors, maybe_whole}; impl<'a> Parser<'a> { /// Parses a statement. This stops just before trailing semicolons on everything but items. /// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed. + /// + /// If `force_collect` is [`ForceCollect::Yes`], forces collection of tokens regardless of + /// whether or not we have attributes. // Public for rustfmt usage. pub(super) fn parse_stmt(&mut self, force_collect: ForceCollect) -> PResult<'a, Option<Stmt>> { Ok(self.parse_stmt_without_recovery(false, force_collect).unwrap_or_else(|e| { @@ -66,7 +69,7 @@ impl<'a> Parser<'a> { }); } - Ok(Some(if self.token.is_keyword(kw::Let) { + let stmt = if self.token.is_keyword(kw::Let) { self.collect_tokens(None, attrs, force_collect, |this, attrs| { this.expect_keyword(kw::Let)?; let local = this.parse_local(attrs)?; @@ -163,7 +166,10 @@ impl<'a> Parser<'a> { } else { self.error_outer_attrs(attrs); return Ok(None); - })) + }; + + self.maybe_augment_stashed_expr_in_pats_with_suggestions(&stmt); + Ok(Some(stmt)) } fn parse_stmt_path_start(&mut self, lo: Span, attrs: AttrWrapper) -> PResult<'a, Stmt> { |
