mirror of
https://github.com/rust-lang/rust.git
synced 2026-07-26 17:42:22 -04:00
Rollup merge of #157668 - jdonszelmann:matches-must-match-exhaustively, r=lqd
Add test for matches in `rustc_must_match_exhaustively` r? @lcnr
This commit is contained in:
@@ -46,6 +46,9 @@ fn foo(f: Foo) {
|
||||
|
||||
let Foo::A { .. } = f else { loop {} };
|
||||
//~^ ERROR match is not exhaustive
|
||||
|
||||
matches!(f, Foo::A { .. });
|
||||
//~^ ERROR match is not exhaustive
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
@@ -83,5 +83,21 @@ note: using `let else` only matches on one variant (try using `match`)
|
||||
LL | let Foo::A { .. } = f else { loop {} };
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error: match is not exhaustive
|
||||
--> $DIR/must_match_exhaustively.rs:50:14
|
||||
|
|
||||
LL | #[rustc_must_match_exhaustively]
|
||||
| -------------------------------- required because of this attribute
|
||||
...
|
||||
LL | matches!(f, Foo::A { .. });
|
||||
| ^
|
||||
|
|
||||
= help: explicitly list all variants of the enum in a `match`
|
||||
note: because of this wildcard pattern
|
||||
--> $DIR/must_match_exhaustively.rs:50:5
|
||||
|
|
||||
LL | matches!(f, Foo::A { .. });
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
||||
Reference in New Issue
Block a user