Skip to content

Commit ef087b0

Browse files
committed
Sync from rust 2a023bf80a6fbd6a06d5460a34eb247b986286ed
2 parents 503612e + 08dac6f commit ef087b0

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/constant.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ pub(crate) fn codegen_const_value<'tcx>(
176176
fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
177177
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
178178
}
179+
GlobalAlloc::TypeId { .. } => {
180+
return CValue::const_val(
181+
fx,
182+
layout,
183+
ScalarInt::try_from_target_usize(offset.bytes(), fx.tcx).unwrap(),
184+
);
185+
}
179186
GlobalAlloc::Static(def_id) => {
180187
assert!(fx.tcx.is_static(def_id));
181188
let data_id = data_id_for_static(
@@ -362,6 +369,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
362369
GlobalAlloc::Memory(alloc) => alloc,
363370
GlobalAlloc::Function { .. }
364371
| GlobalAlloc::Static(_)
372+
| GlobalAlloc::TypeId { .. }
365373
| GlobalAlloc::VTable(..) => {
366374
unreachable!()
367375
}
@@ -473,6 +481,11 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
473481
.principal()
474482
.map(|principal| tcx.instantiate_bound_regions_with_erased(principal)),
475483
),
484+
GlobalAlloc::TypeId { .. } => {
485+
// Nothing to do, the bytes/offset of this pointer have already been written together with all other bytes,
486+
// so we just need to drop this provenance.
487+
continue;
488+
}
476489
GlobalAlloc::Static(def_id) => {
477490
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL)
478491
{

0 commit comments

Comments
 (0)