1
Fork 0

guarantee that char and u32 are ABI-compatible

This commit is contained in:
Ralf Jung 2023-11-18 08:24:02 +01:00
parent e6dade96f4
commit b4f3f2aeac
4 changed files with 19 additions and 5 deletions

View file

@ -384,10 +384,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
}
// Compatible integer types (in particular, usize vs ptr-sized-u32/u64).
// `char` counts as `u32.`
let int_ty = |ty: Ty<'tcx>| {
Some(match ty.kind() {
ty::Int(ity) => (Integer::from_int_ty(&self.tcx, *ity), /* signed */ true),
ty::Uint(uty) => (Integer::from_uint_ty(&self.tcx, *uty), /* signed */ false),
ty::Char => (Integer::I32, /* signed */ false),
_ => return None,
})
};