Add support for untagged unions.

This commit is contained in:
Scott Olson 2016-12-07 23:25:47 -08:00
parent a64d30b2c1
commit bc5bd71922
2 changed files with 21 additions and 1 deletions

View File

@ -557,7 +557,25 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
self.assign_fields(dest, offsets, operands)?;
}
_ => return Err(EvalError::Unimplemented(format!("can't handle destination layout {:?} when assigning {:?}", dest_layout, kind))),
UntaggedUnion { .. } => {
assert_eq!(operands.len(), 1);
let operand = &operands[0];
let value = self.eval_operand(operand)?;
let value_ty = self.operand_ty(operand);
// FIXME(solson)
let dest = self.force_allocation(dest)?;
self.write_value(value, dest, value_ty)?;
}
_ => {
return Err(EvalError::Unimplemented(format!(
"can't handle destination layout {:?} when assigning {:?}",
dest_layout,
kind
)));
}
}
}

View File

@ -209,6 +209,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
nonnull.offsets[field]
}
UntaggedUnion { .. } => return Ok(base),
_ => bug!("field access on non-product type: {:?}", base_layout),
};