about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc
diff options
context:
space:
mode:
authorOli Scherer <github333195615777966@oli-obk.de>2025-03-12 10:26:37 +0000
committerOli Scherer <github333195615777966@oli-obk.de>2025-07-09 16:37:11 +0000
commit486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1 (patch)
tree6016dd4aa95f8637e464cda9688a84c5a1002bc4 /compiler/rustc_codegen_gcc
parent6b3ae3f6e45a33c2d95fa0362c9b2593e567fd34 (diff)
downloadrust-486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1.tar.gz
rust-486ffda9dcd0d4ef0a09d81e6ce5f241e77526a1.zip
Add opaque TypeId handles for CTFE
Diffstat (limited to 'compiler/rustc_codegen_gcc')
-rw-r--r--compiler/rustc_codegen_gcc/src/common.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_gcc/src/common.rs b/compiler/rustc_codegen_gcc/src/common.rs
index 32713eb56c6..28848ca6184 100644
--- a/compiler/rustc_codegen_gcc/src/common.rs
+++ b/compiler/rustc_codegen_gcc/src/common.rs
@@ -1,7 +1,6 @@
 use gccjit::{LValue, RValue, ToRValue, Type};
-use rustc_abi as abi;
-use rustc_abi::HasDataLayout;
 use rustc_abi::Primitive::Pointer;
+use rustc_abi::{self as abi, HasDataLayout};
 use rustc_codegen_ssa::traits::{
     BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods,
 };
@@ -282,6 +281,13 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
                         let init = self.const_data_from_alloc(alloc);
                         self.static_addr_of(init, alloc.inner().align, None)
                     }
+                    GlobalAlloc::TypeId { .. } => {
+                        let val = self.const_usize(offset.bytes());
+                        // This is still a variable of pointer type, even though we only use the provenance
+                        // of that pointer in CTFE and Miri. But to make LLVM's type system happy,
+                        // we need an int-to-ptr cast here (it doesn't matter at all which provenance that picks).
+                        return self.context.new_cast(None, val, ty);
+                    }
                     GlobalAlloc::Static(def_id) => {
                         assert!(self.tcx.is_static(def_id));
                         self.get_static(def_id).get_address(None)