mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 14:01:51 +00:00
Don't ICE for postfix match after as
This commit is contained in:
parent
36b6f9b58e
commit
9d116e8e18
@ -860,6 +860,7 @@ impl<'a> Parser<'a> {
|
||||
ExprKind::MethodCall(_) => "a method call",
|
||||
ExprKind::Call(_, _) => "a function call",
|
||||
ExprKind::Await(_, _) => "`.await`",
|
||||
ExprKind::Match(_, _, MatchKind::Postfix) => "a postfix match",
|
||||
ExprKind::Err(_) => return Ok(with_postfix),
|
||||
_ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"),
|
||||
}
|
||||
|
7
tests/ui/match/postfix-match/match-after-as.rs
Normal file
7
tests/ui/match/postfix-match/match-after-as.rs
Normal file
@ -0,0 +1,7 @@
|
||||
#![feature(postfix_match)]
|
||||
|
||||
fn main() {
|
||||
1 as i32.match {};
|
||||
//~^ ERROR cast cannot be followed by a postfix match
|
||||
//~| ERROR non-exhaustive patterns
|
||||
}
|
28
tests/ui/match/postfix-match/match-after-as.stderr
Normal file
28
tests/ui/match/postfix-match/match-after-as.stderr
Normal file
@ -0,0 +1,28 @@
|
||||
error: cast cannot be followed by a postfix match
|
||||
--> $DIR/match-after-as.rs:4:5
|
||||
|
|
||||
LL | 1 as i32.match {};
|
||||
| ^^^^^^^^
|
||||
|
|
||||
help: try surrounding the expression in parentheses
|
||||
|
|
||||
LL | (1 as i32).match {};
|
||||
| + +
|
||||
|
||||
error[E0004]: non-exhaustive patterns: type `i32` is non-empty
|
||||
--> $DIR/match-after-as.rs:4:5
|
||||
|
|
||||
LL | 1 as i32.match {};
|
||||
| ^^^^^^^^
|
||||
|
|
||||
= note: the matched value is of type `i32`
|
||||
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown
|
||||
|
|
||||
LL ~ 1 as i32 {
|
||||
LL + _ => todo!(),
|
||||
LL ~ };
|
||||
|
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0004`.
|
Loading…
Reference in New Issue
Block a user