We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9b66df4 commit 509054dCopy full SHA for 509054d
src/discriminant.rs
@@ -26,12 +26,15 @@ pub(crate) fn codegen_set_discriminant<'tcx>(
26
variants: _,
27
} => {
28
let ptr = place.place_field(fx, mir::Field::new(tag_field));
29
- let to = layout
30
- .ty
31
- .discriminant_for_variant(fx.tcx, variant_index)
32
- .unwrap()
33
- .val
34
- .into();
+ let to = ty::ScalarInt::try_from_uint(
+ layout
+ .ty
+ .discriminant_for_variant(fx.tcx, variant_index)
+ .unwrap()
+ .val,
35
+ ptr.layout().size,
36
+ )
37
+ .unwrap();
38
let discr = CValue::const_val(fx, ptr.layout(), to);
39
ptr.write_cvalue(fx, discr);
40
}
0 commit comments