diff options
| author | Wesley Wiser <wwiser@gmail.com> | 2019-09-17 05:48:38 -0400 |
|---|---|---|
| committer | Wesley Wiser <wwiser@gmail.com> | 2019-09-27 20:11:13 -0400 |
| commit | 4e58e2e3a3f3cda15bad6cbb87242eaf555dda85 (patch) | |
| tree | d5fdb658c1a81fbd60ce2ef56ddb226f03de5752 | |
| parent | 93335141021df7d53ba597f6315a8014fe21195f (diff) | |
| download | rust-4e58e2e3a3f3cda15bad6cbb87242eaf555dda85.tar.gz rust-4e58e2e3a3f3cda15bad6cbb87242eaf555dda85.zip | |
Work around for #64506
| -rw-r--r-- | src/librustc/mir/interpret/error.rs | 6 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/place.rs | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 0328f93859b..4da5d979cc3 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -397,6 +397,10 @@ pub enum UnsupportedOpInfo<'tcx> { /// while evaluating `const` items. ReadOfStaticInConst, + /// FIXME(#64506) Error used to work around accessing projections of + /// uninhabited types. + UninhabitedValue, + // -- Everything below is not categorized yet -- FunctionAbiMismatch(Abi, Abi), FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>), @@ -564,6 +568,8 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> { write!(f, "{}", msg), ReadOfStaticInConst => write!(f, "tried to read from a static during const evaluation"), + UninhabitedValue => + write!(f, "tried to use an uninhabited value"), } } } diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index f9ba1452d64..1ece913eb59 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -9,7 +9,7 @@ use rustc::mir; use rustc::mir::interpret::truncate; use rustc::ty::{self, Ty}; use rustc::ty::layout::{ - self, Size, Align, LayoutOf, TyLayout, HasDataLayout, VariantIdx, PrimitiveExt + self, Size, Abi, Align, LayoutOf, TyLayout, HasDataLayout, VariantIdx, PrimitiveExt }; use rustc::ty::TypeFoldable; @@ -385,6 +385,10 @@ where stride * field } layout::FieldPlacement::Union(count) => { + // FIXME(#64506) `UninhabitedValue` can be removed when this issue is resolved + if base.layout.abi == Abi::Uninhabited { + throw_unsup!(UninhabitedValue); + } assert!(field < count as u64, "Tried to access field {} of union with {} fields", field, count); // Offset is always 0 |
