about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-12-23 15:33:34 +0000
committerbors <bors@rust-lang.org>2023-12-23 15:33:34 +0000
commit5eccfc388e70d45c98b859af5c14f397ae1c206e (patch)
treed64cf1373700cbffce600ee3034e7ad160a809dd /compiler/rustc_parse/src
parentedcbcc768a484d52deb315e7c583fe4b2ab4f25b (diff)
parent2e09941bd7e3f6bca1ecec85d212d0ee5a6899c5 (diff)
downloadrust-5eccfc388e70d45c98b859af5c14f397ae1c206e.tar.gz
rust-5eccfc388e70d45c98b859af5c14f397ae1c206e.zip
Auto merge of #119256 - matthiaskrgr:rollup-q0q5c1d, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #119231 (Clairify `ast::PatKind::Struct` presese of `..` by using an enum instead of a bool)
 - #119232 (Fix doc typos)
 - #119245 (Improve documentation for using warning blocks in documentation)
 - #119248 (remove dead inferred outlives testing code)
 - #119249 (Add spastorino to users_on_vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src')
-rw-r--r--compiler/rustc_parse/src/parser/pat.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_parse/src/parser/pat.rs b/compiler/rustc_parse/src/parser/pat.rs
index 56a3f5ce3c2..11c4b8fae7c 100644
--- a/compiler/rustc_parse/src/parser/pat.rs
+++ b/compiler/rustc_parse/src/parser/pat.rs
@@ -15,7 +15,7 @@ use rustc_ast::ptr::P;
 use rustc_ast::token::{self, Delimiter};
 use rustc_ast::{
     self as ast, AttrVec, BindingAnnotation, ByRef, Expr, ExprKind, MacCall, Mutability, Pat,
-    PatField, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
+    PatField, PatFieldsRest, PatKind, Path, QSelf, RangeEnd, RangeSyntax,
 };
 use rustc_ast_pretty::pprust;
 use rustc_errors::{Applicability, DiagnosticBuilder, PResult};
@@ -891,7 +891,8 @@ impl<'a> Parser<'a> {
             e.span_label(path.span, "while parsing the fields for this pattern");
             e.emit();
             self.recover_stmt();
-            (ThinVec::new(), true)
+            // When recovering, pretend we had `Foo { .. }`, to avoid cascading errors.
+            (ThinVec::new(), PatFieldsRest::Rest)
         });
         self.bump();
         Ok(PatKind::Struct(qself, path, fields, etc))
@@ -965,9 +966,9 @@ impl<'a> Parser<'a> {
     }
 
     /// Parses the fields of a struct-like pattern.
-    fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, bool)> {
+    fn parse_pat_fields(&mut self) -> PResult<'a, (ThinVec<PatField>, PatFieldsRest)> {
         let mut fields = ThinVec::new();
-        let mut etc = false;
+        let mut etc = PatFieldsRest::None;
         let mut ate_comma = true;
         let mut delayed_err: Option<DiagnosticBuilder<'a>> = None;
         let mut first_etc_and_maybe_comma_span = None;
@@ -1001,7 +1002,7 @@ impl<'a> Parser<'a> {
                 || self.check_noexpect(&token::DotDotDot)
                 || self.check_keyword(kw::Underscore)
             {
-                etc = true;
+                etc = PatFieldsRest::Rest;
                 let mut etc_sp = self.token.span;
                 if first_etc_and_maybe_comma_span.is_none() {
                     if let Some(comma_tok) = self