Skip to content

Commit e602205

Browse files
authored
Rollup merge of rust-lang#54893 - dsciarra:issue-54379, r=pnkfelix
Fix internal compiler error on malformed match arm pattern. Issue: rust-lang#54379
2 parents 5750176 + b7248d5 commit e602205

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,6 +3883,9 @@ impl<'a> Parser<'a> {
38833883
// check that a comma comes after every field
38843884
if !ate_comma {
38853885
let err = self.struct_span_err(self.prev_span, "expected `,`");
3886+
if let Some(mut delayed) = delayed_err {
3887+
delayed.emit();
3888+
}
38863889
return Err(err);
38873890
}
38883891
ate_comma = false;

src/test/ui/resolve/issue-54379.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
struct MyStruct {
11+
pub s1: Option<String>,
12+
}
13+
14+
fn main() {
15+
let thing = MyStruct { s1: None };
16+
17+
match thing {
18+
MyStruct { .., Some(_) } => {},
19+
_ => {}
20+
}
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error: expected `}`, found `,`
2+
--> $DIR/issue-54379.rs:18:22
3+
|
4+
LL | MyStruct { .., Some(_) } => {},
5+
| --^
6+
| | |
7+
| | expected `}`
8+
| `..` must be at the end and cannot have a trailing comma
9+
10+
error: expected `,`
11+
--> $DIR/issue-54379.rs:18:24
12+
|
13+
LL | MyStruct { .., Some(_) } => {},
14+
| ^^^^
15+
16+
error[E0027]: pattern does not mention field `s1`
17+
--> $DIR/issue-54379.rs:18:9
18+
|
19+
LL | MyStruct { .., Some(_) } => {},
20+
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing field `s1`
21+
22+
error: aborting due to 3 previous errors
23+
24+
For more information about this error, try `rustc --explain E0027`.

0 commit comments

Comments
 (0)