Skip to content

Commit 9d116e8

Browse files
Don't ICE for postfix match after as
1 parent 36b6f9b commit 9d116e8

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

compiler/rustc_parse/src/parser/expr.rs

+1
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ impl<'a> Parser<'a> {
860860
ExprKind::MethodCall(_) => "a method call",
861861
ExprKind::Call(_, _) => "a function call",
862862
ExprKind::Await(_, _) => "`.await`",
863+
ExprKind::Match(_, _, MatchKind::Postfix) => "a postfix match",
863864
ExprKind::Err(_) => return Ok(with_postfix),
864865
_ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"),
865866
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![feature(postfix_match)]
2+
3+
fn main() {
4+
1 as i32.match {};
5+
//~^ ERROR cast cannot be followed by a postfix match
6+
//~| ERROR non-exhaustive patterns
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error: cast cannot be followed by a postfix match
2+
--> $DIR/match-after-as.rs:4:5
3+
|
4+
LL | 1 as i32.match {};
5+
| ^^^^^^^^
6+
|
7+
help: try surrounding the expression in parentheses
8+
|
9+
LL | (1 as i32).match {};
10+
| + +
11+
12+
error[E0004]: non-exhaustive patterns: type `i32` is non-empty
13+
--> $DIR/match-after-as.rs:4:5
14+
|
15+
LL | 1 as i32.match {};
16+
| ^^^^^^^^
17+
|
18+
= note: the matched value is of type `i32`
19+
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
20+
|
21+
LL ~ 1 as i32 {
22+
LL + _ => todo!(),
23+
LL ~ };
24+
|
25+
26+
error: aborting due to 2 previous errors
27+
28+
For more information about this error, try `rustc --explain E0004`.

0 commit comments

Comments
 (0)