diff options
| author | bors <bors@rust-lang.org> | 2023-12-11 04:13:19 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-12-11 04:13:19 +0000 |
| commit | e299752868656b6b355864d66659fe542a525ec5 (patch) | |
| tree | 9adeae6af035259bd65793aa4ddb7c433f8f7980 /compiler/rustc_const_eval/src/interpret | |
| parent | 1cb200cfeb7ee99d51453f31efbe1b4cf8b085d8 (diff) | |
| parent | b4f3f2aeacfc629e57eca6cabc27a00cf4cf2375 (diff) | |
| download | rust-e299752868656b6b355864d66659fe542a525ec5.tar.gz rust-e299752868656b6b355864d66659fe542a525ec5.zip | |
Auto merge of #118032 - RalfJung:char-u32, r=Mark-Simulacrum
guarantee that char and u32 are ABI-compatible In https://github.com/rust-lang/rust/pull/116894 we added a guarantee that `char` has the same alignment as `u32`, but there is still one axis where these types could differ: function call ABI. So let's nail that down as well: in a function signature, `char` and `u32` are completely equivalent. This is a new stable guarantee, so it will need t-lang approval.
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/terminator.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index e48506bd083..2358caffc9b 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -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, }) }; |
