Don't ICE for postfix match after as
This commit is contained in:
parent
36b6f9b58e
commit
9d116e8e18
3 changed files with 36 additions and 0 deletions
|
@ -860,6 +860,7 @@ impl<'a> Parser<'a> {
|
||||||
ExprKind::MethodCall(_) => "a method call",
|
ExprKind::MethodCall(_) => "a method call",
|
||||||
ExprKind::Call(_, _) => "a function call",
|
ExprKind::Call(_, _) => "a function call",
|
||||||
ExprKind::Await(_, _) => "`.await`",
|
ExprKind::Await(_, _) => "`.await`",
|
||||||
|
ExprKind::Match(_, _, MatchKind::Postfix) => "a postfix match",
|
||||||
ExprKind::Err(_) => return Ok(with_postfix),
|
ExprKind::Err(_) => return Ok(with_postfix),
|
||||||
_ => unreachable!("parse_dot_or_call_expr_with_ shouldn't produce this"),
|
_ => 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…
Add table
Add a link
Reference in a new issue