diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-08-02 14:09:04 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-08-02 14:09:04 +0300 |
| commit | cf318b1f6feef3dc7115bb767d180cd9308fc052 (patch) | |
| tree | 647ca7edcefc3aa33dd84a4badf0c24ce12530ca /src | |
| parent | 7700bd0c540989e56268a4b5b72afa5086040517 (diff) | |
| parent | f8c61da0704f86726139197b3d34381ac3e1334f (diff) | |
| download | rust-cf318b1f6feef3dc7115bb767d180cd9308fc052.tar.gz rust-cf318b1f6feef3dc7115bb767d180cd9308fc052.zip | |
Merge pull request #278 from solson/unions
Process untagged unions
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 277e6e99e75..86e5d855f44 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -955,6 +955,8 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { 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 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { 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 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { 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)) } } |
