mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-02 06:28:20 +03:00
Process untagged unions
This commit is contained in:
@@ -955,6 +955,8 @@ pub fn get_field_ty(&self, ty: Ty<'tcx>, field_index: usize) -> EvalResult<'tcx,
|
||||
let variant_def = adt_def.struct_variant();
|
||||
use rustc::ty::layout::Layout::*;
|
||||
match *self.type_layout(ty)? {
|
||||
UntaggedUnion { ref variants } =>
|
||||
Ok(TyAndPacked { ty: variant_def.fields[field_index].ty(self.tcx, substs), packed: variants.packed }),
|
||||
Univariant { ref variant, .. } =>
|
||||
Ok(TyAndPacked { ty: variant_def.fields[field_index].ty(self.tcx, substs), packed: variant.packed }),
|
||||
_ => Err(EvalError::Unimplemented(format!("get_field_ty can't handle struct type: {:?}, {:?}", ty, ty.sty))),
|
||||
@@ -988,8 +990,9 @@ fn get_field_offset(&self, ty: Ty<'tcx>, field_index: usize) -> EvalResult<'tcx,
|
||||
StructWrappedNullablePointer { ref nonnull, .. } => {
|
||||
Ok(nonnull.offsets[field_index])
|
||||
}
|
||||
UntaggedUnion { .. } => Ok(Size::from_bytes(0)),
|
||||
_ => {
|
||||
let msg = format!("can't handle type: {:?}, with layout: {:?}", ty, layout);
|
||||
let msg = format!("get_field_offset: can't handle type: {:?}, with layout: {:?}", ty, layout);
|
||||
Err(EvalError::Unimplemented(msg))
|
||||
}
|
||||
}
|
||||
@@ -1006,8 +1009,9 @@ pub fn get_field_count(&self, ty: Ty<'tcx>) -> EvalResult<'tcx, u64> {
|
||||
Vector { count , .. } |
|
||||
Array { count, .. } => Ok(count),
|
||||
Scalar { .. } => Ok(0),
|
||||
UntaggedUnion { .. } => Ok(1),
|
||||
_ => {
|
||||
let msg = format!("can't handle type: {:?}, with layout: {:?}", ty, layout);
|
||||
let msg = format!("get_field_count: can't handle type: {:?}, with layout: {:?}", ty, layout);
|
||||
Err(EvalError::Unimplemented(msg))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user