Skip to content

Commit 3d5b177

Browse files
committed
Add opaque TypeId handles for CTFE
1 parent 981dda8 commit 3d5b177

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/common.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use gccjit::{LValue, RValue, ToRValue, Type};
2-
use rustc_abi as abi;
3-
use rustc_abi::HasDataLayout;
42
use rustc_abi::Primitive::Pointer;
3+
use rustc_abi::{self as abi, HasDataLayout};
54
use rustc_codegen_ssa::traits::{
65
BaseTypeCodegenMethods, ConstCodegenMethods, MiscCodegenMethods, StaticCodegenMethods,
76
};
@@ -282,6 +281,13 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
282281
let init = self.const_data_from_alloc(alloc);
283282
self.static_addr_of(init, alloc.inner().align, None)
284283
}
284+
GlobalAlloc::TypeId { .. } => {
285+
let val = self.const_usize(offset.bytes());
286+
// This is still a variable of pointer type, even though we only use the provenance
287+
// of that pointer in CTFE and Miri. But to make LLVM's type system happy,
288+
// we need an int-to-ptr cast here (it doesn't matter at all which provenance that picks).
289+
return self.context.new_cast(None, val, ty);
290+
}
285291
GlobalAlloc::Static(def_id) => {
286292
assert!(self.tcx.is_static(def_id));
287293
self.get_static(def_id).get_address(None)

0 commit comments

Comments
 (0)