Clarify undecided semantics

This commit is contained in:
varkor 2018-11-20 21:33:57 +00:00
parent d2b340758b
commit 32a8dec889
3 changed files with 10 additions and 4 deletions

View file

@ -169,6 +169,7 @@ impl<'a, 'gcx, 'tcx> VariantDef {
{
let is_enum = match adt_kind {
// For now, `union`s are never considered uninhabited.
// The precise semantics of inhabitedness with respect to unions is currently undecided.
AdtKind::Union => return DefIdForest::empty(),
AdtKind::Enum => true,
AdtKind::Struct => false,
@ -267,6 +268,8 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
// References to uninitialised memory is valid for any type, including
// uninhabited types, in unsafe code, so we treat all references as
// inhabited.
// The precise semantics of inhabitedness with respect to references is currently
// undecided.
Ref(..) => DefIdForest::empty(),
_ => DefIdForest::empty(),

View file

@ -1,3 +1,6 @@
// 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)]

View file

@ -1,23 +1,23 @@
error[E0004]: non-exhaustive patterns: type &'static ! is non-empty
--> $DIR/always-inhabited-union-ref.rs:20:11
--> $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:20:11
--> $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:24:11
--> $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:24:11
--> $DIR/always-inhabited-union-ref.rs:27:11
|
LL | match uninhab_union() {
| ^^^^^^^^^^^^^^^