Skip to content

Commit 8dfc8db

Browse files
committed
forgot about multivariant enum casts
1 parent 2ad303e commit 8dfc8db

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librustc_mir/interpret/cast.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
139139
// Floating point
140140
Float(FloatTy::F32) => self.cast_from_float(val.to_f32()?, dest_layout.ty),
141141
Float(FloatTy::F64) => self.cast_from_float(val.to_f64()?, dest_layout.ty),
142-
// Integer(-like), including fn ptr casts
142+
// Integer(-like), including fn ptr casts and casts from enums that
143+
// are represented as integers (this excludes univariant enums, which
144+
// are handled in `cast` directly).
143145
_ => {
144146
assert!(
145-
src_layout.ty.is_bool() || src_layout.ty.is_char() ||
146-
src_layout.ty.is_integral() || src_layout.ty.is_region_ptr() ||
147-
src_layout.ty.is_unsafe_ptr() || src_layout.ty.is_fn_ptr(),
147+
src_layout.ty.is_bool() || src_layout.ty.is_char() ||
148+
src_layout.ty.is_enum() || src_layout.ty.is_integral() ||
149+
src_layout.ty.is_unsafe_ptr() || src_layout.ty.is_fn_ptr() ||
150+
src_layout.ty.is_region_ptr(),
148151
"Unexpected cast from type {:?}", src_layout.ty
149152
);
150153
match val.to_bits_or_ptr(src_layout.size, self) {

0 commit comments

Comments
 (0)