Skip to content

Commit b7248d5

Browse files
committed
Fix internal compiler error on malformed match arm pattern.
Issue: 54379
1 parent 987a50b commit b7248d5

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

src/libsyntax/parse/parser.rs

+3
Original file line numberDiff line numberDiff line change
@@ -3866,6 +3866,9 @@ impl<'a> Parser<'a> {
38663866
// check that a comma comes after every field
38673867
if !ate_comma {
38683868
let err = self.struct_span_err(self.prev_span, "expected `,`");
3869+
if let Some(mut delayed) = delayed_err {
3870+
delayed.emit();
3871+
}
38693872
return Err(err);
38703873
}
38713874
ate_comma = false;

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

+21
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+
}
+24
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)