forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#56110 - varkor:inhabitedness-union-enum, r=…
…cramertj Consider references and unions potentially inhabited during privacy-respecting inhabitedness checks It isn't settled exactly how references to uninhabited types and unions of uninhabited types should act, but we should be more conservative here, as it's likely it will be permitted to soundly have values of such types. This will also be more important in light of the changes at rust-lang#54125. cc @RalfJung
- Loading branch information
Showing
9 changed files
with
105 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// The precise semantics of inhabitedness with respect to unions and references is currently | ||
// undecided. This test file currently checks a conservative choice. | ||
|
||
#![feature(exhaustive_patterns)] | ||
#![feature(never_type)] | ||
|
||
#![allow(dead_code)] | ||
#![allow(unreachable_code)] | ||
|
||
pub union Foo { | ||
foo: !, | ||
} | ||
|
||
fn uninhab_ref() -> &'static ! { | ||
unimplemented!() | ||
} | ||
|
||
fn uninhab_union() -> Foo { | ||
unimplemented!() | ||
} | ||
|
||
fn match_on_uninhab() { | ||
match uninhab_ref() { | ||
//~^ ERROR non-exhaustive patterns: type `&'static !` is non-empty | ||
} | ||
|
||
match uninhab_union() { | ||
//~^ ERROR non-exhaustive patterns: type `Foo` is non-empty | ||
} | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
error[E0004]: non-exhaustive patterns: type `&'static !` is non-empty | ||
--> $DIR/always-inhabited-union-ref.rs:23:11 | ||
| | ||
LL | match uninhab_ref() { | ||
| ^^^^^^^^^^^^^ | ||
| | ||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
--> $DIR/always-inhabited-union-ref.rs:23:11 | ||
| | ||
LL | match uninhab_ref() { | ||
| ^^^^^^^^^^^^^ | ||
|
||
error[E0004]: non-exhaustive patterns: type `Foo` is non-empty | ||
--> $DIR/always-inhabited-union-ref.rs:27:11 | ||
| | ||
LL | match uninhab_union() { | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms | ||
--> $DIR/always-inhabited-union-ref.rs:27:11 | ||
| | ||
LL | match uninhab_union() { | ||
| ^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0004`. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters