diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index fb5ff7e8f98..665308eda2e 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3620,7 +3620,15 @@ impl<'a> Parser<'a> { let mut etc_span = None; while self.token != token::CloseDelim(token::Brace) { - let attrs = self.parse_outer_attributes()?; + let attrs = match self.parse_outer_attributes() { + Ok(attrs) => attrs, + Err(err) => { + if let Some(mut delayed) = delayed_err { + delayed.emit(); + } + return Err(err); + }, + }; let lo = self.token.span; // check that a comma comes after every field diff --git a/src/test/ui/parser/issue-63135.rs b/src/test/ui/parser/issue-63135.rs new file mode 100644 index 00000000000..d5f5f1469f3 --- /dev/null +++ b/src/test/ui/parser/issue-63135.rs @@ -0,0 +1,3 @@ +// error-pattern: aborting due to 6 previous errors + +fn i(n{...,f # diff --git a/src/test/ui/parser/issue-63135.stderr b/src/test/ui/parser/issue-63135.stderr new file mode 100644 index 00000000000..c0286d90af7 --- /dev/null +++ b/src/test/ui/parser/issue-63135.stderr @@ -0,0 +1,44 @@ +error: this file contains an un-closed delimiter + --> $DIR/issue-63135.rs:3:16 + | +LL | fn i(n{...,f # + | - - ^ + | | | + | | un-closed delimiter + | un-closed delimiter + +error: expected field pattern, found `...` + --> $DIR/issue-63135.rs:3:8 + | +LL | fn i(n{...,f # + | ^^^ help: to omit remaining fields, use one fewer `.`: `..` + +error: expected `}`, found `,` + --> $DIR/issue-63135.rs:3:11 + | +LL | fn i(n{...,f # + | ---^ + | | | + | | expected `}` + | `..` must be at the end and cannot have a trailing comma + +error: expected `[`, found `}` + --> $DIR/issue-63135.rs:3:15 + | +LL | fn i(n{...,f # + | ^ expected `[` + +error: expected `:`, found `)` + --> $DIR/issue-63135.rs:3:15 + | +LL | fn i(n{...,f # + | ^ expected `:` + +error: expected one of `->`, `where`, or `{`, found `` + --> $DIR/issue-63135.rs:3:15 + | +LL | fn i(n{...,f # + | ^ expected one of `->`, `where`, or `{` here + +error: aborting due to 6 previous errors +