Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 6 additions & 4 deletions compiler/rustc_mir_build/src/thir/pattern/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,10 +702,12 @@ impl<'p, 'tcx> MatchVisitor<'p, 'tcx> {
&& adt.is_enum()
&& let Constructor::Variant(variant_index) = witness_1.ctor()
{
let variant = adt.variant(*variant_index);
let inhabited = variant.inhabited_predicate(self.tcx, *adt).instantiate(self.tcx, args);
assert!(inhabited.apply(self.tcx, cx.param_env, cx.module));
!inhabited.apply_ignore_module(self.tcx, cx.param_env)
let variant_inhabited = adt
.variant(*variant_index)
.inhabited_predicate(self.tcx, *adt)
.instantiate(self.tcx, args);
variant_inhabited.apply(self.tcx, cx.param_env, cx.module)
&& !variant_inhabited.apply_ignore_module(self.tcx, cx.param_env)
} else {
false
};
Expand Down
44 changes: 22 additions & 22 deletions tests/ui/pattern/usefulness/empty-types.exhaustive_patterns.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -254,39 +254,39 @@ LL | _ => {}
= note: this pattern matches no values because `!` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:279:9
--> $DIR/empty-types.rs:281:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:282:9
--> $DIR/empty-types.rs:284:9
|
LL | (_, _) => {}
| ^^^^^^
|
= note: this pattern matches no values because `(!, !)` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:285:9
--> $DIR/empty-types.rs:287:9
|
LL | Ok(_) => {}
| ^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:286:9
--> $DIR/empty-types.rs:288:9
|
LL | Err(_) => {}
| ^^^^^^
|
= note: this pattern matches no values because `Result<!, !>` is uninhabited

error[E0004]: non-exhaustive patterns: type `&[!]` is non-empty
--> $DIR/empty-types.rs:318:11
--> $DIR/empty-types.rs:327:11
|
LL | match slice_never {}
| ^^^^^^^^^^^
Expand All @@ -300,7 +300,7 @@ LL + }
|

error[E0004]: non-exhaustive patterns: `&[]` not covered
--> $DIR/empty-types.rs:329:11
--> $DIR/empty-types.rs:338:11
|
LL | match slice_never {
| ^^^^^^^^^^^ pattern `&[]` not covered
Expand All @@ -313,7 +313,7 @@ LL + &[] => todo!()
|

error[E0004]: non-exhaustive patterns: `&[]` not covered
--> $DIR/empty-types.rs:343:11
--> $DIR/empty-types.rs:352:11
|
LL | match slice_never {
| ^^^^^^^^^^^ pattern `&[]` not covered
Expand All @@ -327,7 +327,7 @@ LL + &[] => todo!()
|

error[E0004]: non-exhaustive patterns: type `[!]` is non-empty
--> $DIR/empty-types.rs:350:11
--> $DIR/empty-types.rs:359:11
|
LL | match *slice_never {}
| ^^^^^^^^^^^^
Expand All @@ -341,31 +341,31 @@ LL + }
|

error: unreachable pattern
--> $DIR/empty-types.rs:359:9
--> $DIR/empty-types.rs:368:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `[!; 3]` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:362:9
--> $DIR/empty-types.rs:371:9
|
LL | [_, _, _] => {}
| ^^^^^^^^^
|
= note: this pattern matches no values because `[!; 3]` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:365:9
--> $DIR/empty-types.rs:374:9
|
LL | [_, ..] => {}
| ^^^^^^^
|
= note: this pattern matches no values because `[!; 3]` is uninhabited

error[E0004]: non-exhaustive patterns: type `[!; 0]` is non-empty
--> $DIR/empty-types.rs:379:11
--> $DIR/empty-types.rs:388:11
|
LL | match array_0_never {}
| ^^^^^^^^^^^^^
Expand All @@ -379,15 +379,15 @@ LL + }
|

error: unreachable pattern
--> $DIR/empty-types.rs:386:9
--> $DIR/empty-types.rs:395:9
|
LL | [] => {}
| -- matches all the values already
LL | _ => {}
| ^ unreachable pattern

error[E0004]: non-exhaustive patterns: `[]` not covered
--> $DIR/empty-types.rs:388:11
--> $DIR/empty-types.rs:397:11
|
LL | match array_0_never {
| ^^^^^^^^^^^^^ pattern `[]` not covered
Expand All @@ -401,23 +401,23 @@ LL + [] => todo!()
|

error: unreachable pattern
--> $DIR/empty-types.rs:407:9
--> $DIR/empty-types.rs:416:9
|
LL | Some(_) => {}
| ^^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:412:9
--> $DIR/empty-types.rs:421:9
|
LL | Some(_a) => {}
| ^^^^^^^^
|
= note: this pattern matches no values because `!` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:417:9
--> $DIR/empty-types.rs:426:9
|
LL | None => {}
| ---- matches all the values already
Expand All @@ -426,7 +426,7 @@ LL | _ => {}
| ^ unreachable pattern

error: unreachable pattern
--> $DIR/empty-types.rs:422:9
--> $DIR/empty-types.rs:431:9
|
LL | None => {}
| ---- matches all the values already
Expand All @@ -435,31 +435,31 @@ LL | _a => {}
| ^^ unreachable pattern

error: unreachable pattern
--> $DIR/empty-types.rs:594:9
--> $DIR/empty-types.rs:603:9
|
LL | _ => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:597:9
--> $DIR/empty-types.rs:606:9
|
LL | _x => {}
| ^^
|
= note: this pattern matches no values because `!` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:600:9
--> $DIR/empty-types.rs:609:9
|
LL | _ if false => {}
| ^
|
= note: this pattern matches no values because `!` is uninhabited

error: unreachable pattern
--> $DIR/empty-types.rs:603:9
--> $DIR/empty-types.rs:612:9
|
LL | _x if false => {}
| ^^
Expand Down
Loading
Loading