diff options
| author | varkor <github@varkor.com> | 2018-11-20 21:33:57 +0000 |
|---|---|---|
| committer | varkor <github@varkor.com> | 2018-11-29 20:58:38 +0000 |
| commit | 32a8dec8898a51832560faa95fb3ed6155f0dc7f (patch) | |
| tree | b5e5224006a1edf4738a82b36c1227bbc32ac18f | |
| parent | d2b340758b59cd9f467913ac7baa0b1a8dd3467e (diff) | |
| download | rust-32a8dec8898a51832560faa95fb3ed6155f0dc7f.tar.gz rust-32a8dec8898a51832560faa95fb3ed6155f0dc7f.zip | |
Clarify undecided semantics
| -rw-r--r-- | src/librustc/ty/inhabitedness/mod.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/always-inhabited-union-ref.rs | 3 | ||||
| -rw-r--r-- | src/test/ui/always-inhabited-union-ref.stderr | 8 |
3 files changed, 10 insertions, 4 deletions
diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index 3f9a9c17202..721d5e14ccc 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -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(), diff --git a/src/test/ui/always-inhabited-union-ref.rs b/src/test/ui/always-inhabited-union-ref.rs index 49ef984eb93..b2f2818cb71 100644 --- a/src/test/ui/always-inhabited-union-ref.rs +++ b/src/test/ui/always-inhabited-union-ref.rs @@ -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)] diff --git a/src/test/ui/always-inhabited-union-ref.stderr b/src/test/ui/always-inhabited-union-ref.stderr index 95d3da7be86..bd6179a0b56 100644 --- a/src/test/ui/always-inhabited-union-ref.stderr +++ b/src/test/ui/always-inhabited-union-ref.stderr @@ -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() { | ^^^^^^^^^^^^^^^ |
