diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-03-12 10:26:37 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-07-09 16:37:11 +0000 |
| commit | 486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1 (patch) | |
| tree | 6016dd4aa95f8637e464cda9688a84c5a1002bc4 /compiler/rustc_codegen_cranelift | |
| parent | 6b3ae3f6e45a33c2d95fa0362c9b2593e567fd34 (diff) | |
| download | rust-486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1.tar.gz rust-486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1.zip | |
Add opaque TypeId handles for CTFE
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/constant.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index ed06423b260..85adf0f3716 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -175,6 +175,13 @@ pub(crate) fn codegen_const_value<'tcx>( fx.module.declare_data_in_func(data_id, &mut fx.bcx.func); fx.bcx.ins().global_value(fx.pointer_type, local_data_id) } + GlobalAlloc::TypeId { .. } => { + return CValue::const_val( + fx, + layout, + ScalarInt::try_from_target_usize(offset.bytes(), fx.tcx).unwrap(), + ); + } GlobalAlloc::Static(def_id) => { assert!(fx.tcx.is_static(def_id)); let data_id = data_id_for_static( @@ -360,6 +367,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant GlobalAlloc::Memory(alloc) => alloc, GlobalAlloc::Function { .. } | GlobalAlloc::Static(_) + | GlobalAlloc::TypeId { .. } | GlobalAlloc::VTable(..) => { unreachable!() } @@ -471,6 +479,11 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant .principal() .map(|principal| tcx.instantiate_bound_regions_with_erased(principal)), ), + GlobalAlloc::TypeId { .. } => { + // Nothing to do, the bytes/offset of this pointer have already been written together with all other bytes, + // so we just need to drop this provenance. + continue; + } GlobalAlloc::Static(def_id) => { if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) { |
