Skip to content

Commit

Permalink
Work around for rust-lang#64506
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleywiser authored and andjo403 committed Oct 3, 2019
1 parent 8240858 commit abe1162
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>),
Expand Down Expand Up @@ -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"),
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit abe1162

Please sign in to comment.