Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit abe1162

Browse files
wesleywiserandjo403
authored andcommittedOct 3, 2019
Work around for rust-lang#64506
1 parent 8240858 commit abe1162

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
 

‎src/librustc/mir/interpret/error.rs

+6
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ pub enum UnsupportedOpInfo<'tcx> {
397397
/// while evaluating `const` items.
398398
ReadOfStaticInConst,
399399

400+
/// FIXME(#64506) Error used to work around accessing projections of
401+
/// uninhabited types.
402+
UninhabitedValue,
403+
400404
// -- Everything below is not categorized yet --
401405
FunctionAbiMismatch(Abi, Abi),
402406
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
@@ -564,6 +568,8 @@ impl fmt::Debug for UnsupportedOpInfo<'tcx> {
564568
write!(f, "{}", msg),
565569
ReadOfStaticInConst =>
566570
write!(f, "tried to read from a static during const evaluation"),
571+
UninhabitedValue =>
572+
write!(f, "tried to use an uninhabited value"),
567573
}
568574
}
569575
}

‎src/librustc_mir/interpret/place.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc::mir;
99
use rustc::mir::interpret::truncate;
1010
use rustc::ty::{self, Ty};
1111
use rustc::ty::layout::{
12-
self, Size, Align, LayoutOf, TyLayout, HasDataLayout, VariantIdx, PrimitiveExt
12+
self, Size, Abi, Align, LayoutOf, TyLayout, HasDataLayout, VariantIdx, PrimitiveExt
1313
};
1414
use rustc::ty::TypeFoldable;
1515

@@ -385,6 +385,10 @@ where
385385
stride * field
386386
}
387387
layout::FieldPlacement::Union(count) => {
388+
// FIXME(#64506) `UninhabitedValue` can be removed when this issue is resolved
389+
if base.layout.abi == Abi::Uninhabited {
390+
throw_unsup!(UninhabitedValue);
391+
}
388392
assert!(field < count as u64,
389393
"Tried to access field {} of union with {} fields", field, count);
390394
// Offset is always 0

0 commit comments

Comments
 (0)
Please sign in to comment.