Skip to content

Commit 063064a

Browse files
authored
Rollup merge of rust-lang#157668 - jdonszelmann:matches-must-match-exhaustively, r=lqd
Add test for matches in `rustc_must_match_exhaustively` r? @lcnr
2 parents 10187c1 + ca657d2 commit 063064a

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

tests/ui-fulldeps/internal-lints/must_match_exhaustively.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ fn foo(f: Foo) {
4646

4747
let Foo::A { .. } = f else { loop {} };
4848
//~^ ERROR match is not exhaustive
49+
50+
matches!(f, Foo::A { .. });
51+
//~^ ERROR match is not exhaustive
4952
}
5053

5154
fn main() {}

tests/ui-fulldeps/internal-lints/must_match_exhaustively.stderr

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,21 @@ note: using `let else` only matches on one variant (try using `match`)
8383
LL | let Foo::A { .. } = f else { loop {} };
8484
| ^^^^^^^^^^^^^
8585

86-
error: aborting due to 5 previous errors
86+
error: match is not exhaustive
87+
--> $DIR/must_match_exhaustively.rs:50:14
88+
|
89+
LL | #[rustc_must_match_exhaustively]
90+
| -------------------------------- required because of this attribute
91+
...
92+
LL | matches!(f, Foo::A { .. });
93+
| ^
94+
|
95+
= help: explicitly list all variants of the enum in a `match`
96+
note: because of this wildcard pattern
97+
--> $DIR/must_match_exhaustively.rs:50:5
98+
|
99+
LL | matches!(f, Foo::A { .. });
100+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
101+
102+
error: aborting due to 6 previous errors
87103

0 commit comments

Comments
 (0)