Skip to content

Rollup of 7 pull requests #123416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't ICE for postfix match after as
  • Loading branch information
compiler-errors committed Apr 2, 2024
commit 9d116e8e188a84d97e1b64f54410fda7ec6f2dc6
1 change: 1 addition & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/match/postfix-match/match-after-as.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 28 additions & 0 deletions tests/ui/match/postfix-match/match-after-as.stderr
Original file line number Diff line number Diff line change
@@ -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`.