Skip to content

Commit 79f38bf

Browse files
committed
Process untagged unions
1 parent 393216d commit 79f38bf

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/librustc_mir/interpret/eval_context.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
955955
let variant_def = adt_def.struct_variant();
956956
use rustc::ty::layout::Layout::*;
957957
match *self.type_layout(ty)? {
958+
UntaggedUnion { ref variants } =>
959+
Ok(TyAndPacked { ty: variant_def.fields[field_index].ty(self.tcx, substs), packed: variants.packed }),
958960
Univariant { ref variant, .. } =>
959961
Ok(TyAndPacked { ty: variant_def.fields[field_index].ty(self.tcx, substs), packed: variant.packed }),
960962
_ => Err(EvalError::Unimplemented(format!("get_field_ty can't handle struct type: {:?}, {:?}", ty, ty.sty))),
@@ -988,8 +990,9 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
988990
StructWrappedNullablePointer { ref nonnull, .. } => {
989991
Ok(nonnull.offsets[field_index])
990992
}
993+
UntaggedUnion { .. } => Ok(Size::from_bytes(0)),
991994
_ => {
992-
let msg = format!("can't handle type: {:?}, with layout: {:?}", ty, layout);
995+
let msg = format!("get_field_offset: can't handle type: {:?}, with layout: {:?}", ty, layout);
993996
Err(EvalError::Unimplemented(msg))
994997
}
995998
}
@@ -1006,8 +1009,9 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> {
10061009
Vector { count , .. } |
10071010
Array { count, .. } => Ok(count),
10081011
Scalar { .. } => Ok(0),
1012+
UntaggedUnion { .. } => Ok(1),
10091013
_ => {
1010-
let msg = format!("can't handle type: {:?}, with layout: {:?}", ty, layout);
1014+
let msg = format!("get_field_count: can't handle type: {:?}, with layout: {:?}", ty, layout);
10111015
Err(EvalError::Unimplemented(msg))
10121016
}
10131017
}

0 commit comments

Comments
 (0)