Work around for #64506
This commit is contained in:
parent
9333514102
commit
4e58e2e3a3
2 changed files with 11 additions and 1 deletions
|
|
@ -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"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue