Skip to content
Permalink
Browse files

forgot about multivariant enum casts

  • Loading branch information...
RalfJung committed Jun 9, 2019
1 parent 2ad303e commit 8dfc8db235e205c60b56e0753996399a6f66f3e1
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/librustc_mir/interpret/cast.rs
@@ -139,12 +139,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
// Floating point
Float(FloatTy::F32) => self.cast_from_float(val.to_f32()?, dest_layout.ty),
Float(FloatTy::F64) => self.cast_from_float(val.to_f64()?, dest_layout.ty),
// Integer(-like), including fn ptr casts
// Integer(-like), including fn ptr casts and casts from enums that
// are represented as integers (this excludes univariant enums, which
// are handled in `cast` directly).
_ => {
assert!(
src_layout.ty.is_bool() || src_layout.ty.is_char() ||
src_layout.ty.is_integral() || src_layout.ty.is_region_ptr() ||
src_layout.ty.is_unsafe_ptr() || src_layout.ty.is_fn_ptr(),
src_layout.ty.is_bool() || src_layout.ty.is_char() ||
src_layout.ty.is_enum() || src_layout.ty.is_integral() ||
src_layout.ty.is_unsafe_ptr() || src_layout.ty.is_fn_ptr() ||
src_layout.ty.is_region_ptr(),
"Unexpected cast from type {:?}", src_layout.ty
);
match val.to_bits_or_ptr(src_layout.size, self) {

0 comments on commit 8dfc8db

Please sign in to comment.
You can’t perform that action at this time.