Skip to content

Commit 803b6ce

Browse files
committed
Rename GlobalAlloc::Type to TypeId
1 parent 95e10fb commit 803b6ce

File tree

10 files changed

+21
-21
lines changed

10 files changed

+21
-21
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub(crate) fn codegen_const_value<'tcx>(
175175
fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
176176
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
177177
}
178-
GlobalAlloc::Type { .. } => {
178+
GlobalAlloc::TypeId { .. } => {
179179
return CValue::const_val(
180180
fx,
181181
layout,
@@ -367,7 +367,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
367367
GlobalAlloc::Memory(alloc) => alloc,
368368
GlobalAlloc::Function { .. }
369369
| GlobalAlloc::Static(_)
370-
| GlobalAlloc::Type { .. }
370+
| GlobalAlloc::TypeId { .. }
371371
| GlobalAlloc::VTable(..) => {
372372
unreachable!()
373373
}
@@ -479,7 +479,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
479479
.principal()
480480
.map(|principal| tcx.instantiate_bound_regions_with_erased(principal)),
481481
),
482-
GlobalAlloc::Type { .. } => {
482+
GlobalAlloc::TypeId { .. } => {
483483
// Nothing to do, the bytes/offset of this pointer have already been written together with all other bytes,
484484
// so we just need to drop this provenance.
485485
continue;

compiler/rustc_codegen_gcc/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ impl<'gcc, 'tcx> ConstCodegenMethods for CodegenCx<'gcc, 'tcx> {
281281
let init = self.const_data_from_alloc(alloc);
282282
self.static_addr_of(init, alloc.inner().align, None)
283283
}
284-
GlobalAlloc::Type { .. } => {
284+
GlobalAlloc::TypeId { .. } => {
285285
let val = self.const_usize(offset.bytes());
286286
return self.context.new_cast(None, val, ty);
287287
}

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
324324
assert!(!self.tcx.is_thread_local_static(def_id));
325325
self.get_static(def_id)
326326
}
327-
GlobalAlloc::Type { .. } => {
327+
GlobalAlloc::TypeId { .. } => {
328328
// Drop the provenance, the offset contains the bytes of the hash
329329
let llval = self.const_usize(offset.bytes());
330330
return unsafe { llvm::LLVMConstIntToPtr(llval, llty) };

compiler/rustc_const_eval/src/interpret/memory.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
346346
kind = "vtable",
347347
)
348348
}
349-
Some(GlobalAlloc::Type { .. }) => {
349+
Some(GlobalAlloc::TypeId { .. }) => {
350350
err_ub_custom!(
351351
fluent::const_eval_invalid_dealloc,
352352
alloc_id = alloc_id,
@@ -622,7 +622,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
622622
}
623623
Some(GlobalAlloc::Function { .. }) => throw_ub!(DerefFunctionPointer(id)),
624624
Some(GlobalAlloc::VTable(..)) => throw_ub!(DerefVTablePointer(id)),
625-
Some(GlobalAlloc::Type { .. }) => throw_ub!(DerefTypeIdPointer(id)),
625+
Some(GlobalAlloc::TypeId { .. }) => throw_ub!(DerefTypeIdPointer(id)),
626626
None => throw_ub!(PointerUseAfterFree(id, CheckInAllocMsg::MemoryAccess)),
627627
Some(GlobalAlloc::Static(def_id)) => {
628628
assert!(self.tcx.is_static(def_id));
@@ -904,7 +904,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
904904
let (size, align) = global_alloc.size_and_align(*self.tcx, self.typing_env);
905905
let mutbl = global_alloc.mutability(*self.tcx, self.typing_env);
906906
let kind = match global_alloc {
907-
GlobalAlloc::Type { .. }
907+
GlobalAlloc::TypeId { .. }
908908
| GlobalAlloc::Static { .. }
909909
| GlobalAlloc::Memory { .. } => AllocKind::LiveData,
910910
GlobalAlloc::Function { .. } => bug!("We already checked function pointers above"),
@@ -953,7 +953,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
953953
ptr: Pointer<Option<M::Provenance>>,
954954
) -> InterpResult<'tcx, (Ty<'tcx>, Size)> {
955955
let (alloc_id, offset, _meta) = self.ptr_get_alloc_id(ptr, 0)?;
956-
let GlobalAlloc::Type { ty } = self.tcx.global_alloc(alloc_id) else {
956+
let GlobalAlloc::TypeId { ty } = self.tcx.global_alloc(alloc_id) else {
957957
throw_ub_format!("type_id_eq: `TypeId` provenance is not a type id")
958958
};
959959
interp_ok((ty, offset))
@@ -1220,7 +1220,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> std::fmt::Debug for DumpAllocs<'a, 'tcx, M> {
12201220
Some(GlobalAlloc::VTable(ty, dyn_ty)) => {
12211221
write!(fmt, " (vtable: impl {dyn_ty} for {ty})")?;
12221222
}
1223-
Some(GlobalAlloc::Type { ty }) => {
1223+
Some(GlobalAlloc::TypeId { ty }) => {
12241224
write!(fmt, " (typeid for {ty})")?;
12251225
}
12261226
Some(GlobalAlloc::Static(did)) => {

compiler/rustc_middle/src/mir/interpret/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub fn specialized_encode_alloc_id<'tcx, E: TyEncoder<'tcx>>(
128128
ty.encode(encoder);
129129
poly_trait_ref.encode(encoder);
130130
}
131-
GlobalAlloc::Type { ty } => {
131+
GlobalAlloc::TypeId { ty } => {
132132
trace!("encoding {alloc_id:?} with {ty:#?}");
133133
AllocDiscriminant::Type.encode(encoder);
134134
ty.encode(encoder);
@@ -272,7 +272,7 @@ pub enum GlobalAlloc<'tcx> {
272272
Memory(ConstAllocation<'tcx>),
273273
/// The first pointer-sized segment of a type id. On 64 bit systems, the 128 bit type id
274274
/// is split into two segments, on 32 bit systems there are 4 segments, and so on.
275-
Type { ty: Ty<'tcx> },
275+
TypeId { ty: Ty<'tcx> },
276276
}
277277

278278
impl<'tcx> GlobalAlloc<'tcx> {
@@ -311,7 +311,7 @@ impl<'tcx> GlobalAlloc<'tcx> {
311311
pub fn address_space(&self, cx: &impl HasDataLayout) -> AddressSpace {
312312
match self {
313313
GlobalAlloc::Function { .. } => cx.data_layout().instruction_address_space,
314-
GlobalAlloc::Type { .. }
314+
GlobalAlloc::TypeId { .. }
315315
| GlobalAlloc::Static(..)
316316
| GlobalAlloc::Memory(..)
317317
| GlobalAlloc::VTable(..) => AddressSpace::DATA,
@@ -350,7 +350,7 @@ impl<'tcx> GlobalAlloc<'tcx> {
350350
}
351351
}
352352
GlobalAlloc::Memory(alloc) => alloc.inner().mutability,
353-
GlobalAlloc::Type { .. } | GlobalAlloc::Function { .. } | GlobalAlloc::VTable(..) => {
353+
GlobalAlloc::TypeId { .. } | GlobalAlloc::Function { .. } | GlobalAlloc::VTable(..) => {
354354
// These are immutable.
355355
Mutability::Not
356356
}
@@ -399,7 +399,7 @@ impl<'tcx> GlobalAlloc<'tcx> {
399399
(Size::ZERO, tcx.data_layout.pointer_align.abi)
400400
}
401401
// Fake allocation, there's nothing to access here
402-
GlobalAlloc::Type { .. } => (Size::ZERO, Align::ONE),
402+
GlobalAlloc::TypeId { .. } => (Size::ZERO, Align::ONE),
403403
}
404404
}
405405
}
@@ -507,7 +507,7 @@ impl<'tcx> TyCtxt<'tcx> {
507507

508508
/// Generates an [AllocId] for a [core::any::TypeId]. Will get deduplicated.
509509
pub fn reserve_and_set_type_id_alloc(self, ty: Ty<'tcx>) -> AllocId {
510-
self.reserve_and_set_dedup(GlobalAlloc::Type { ty }, 0)
510+
self.reserve_and_set_dedup(GlobalAlloc::TypeId { ty }, 0)
511511
}
512512

513513
/// Interns the `Allocation` and return a new `AllocId`, even if there's already an identical

compiler/rustc_middle/src/mir/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ pub fn write_allocations<'tcx>(
16211621
Some(GlobalAlloc::VTable(ty, dyn_ty)) => {
16221622
write!(w, " (vtable: impl {dyn_ty} for {ty})")?
16231623
}
1624-
Some(GlobalAlloc::Type { ty }) => write!(w, " (typeid for {ty})")?,
1624+
Some(GlobalAlloc::TypeId { ty }) => write!(w, " (typeid for {ty})")?,
16251625
Some(GlobalAlloc::Static(did)) if !tcx.is_foreign_item(did) => {
16261626
write!(w, " (static: {}", tcx.def_path_str(did))?;
16271627
if body.phase <= MirPhase::Runtime(RuntimePhase::PostCleanup)

compiler/rustc_middle/src/ty/print/pretty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
17791779
}
17801780
Some(GlobalAlloc::Function { .. }) => p!("<function>"),
17811781
Some(GlobalAlloc::VTable(..)) => p!("<vtable>"),
1782-
Some(GlobalAlloc::Type { .. }) => p!("<typeid>"),
1782+
Some(GlobalAlloc::TypeId { .. }) => p!("<typeid>"),
17831783
None => p!("<dangling pointer>"),
17841784
}
17851785
return Ok(());

compiler/rustc_monomorphize/src/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1219,7 +1219,7 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt
12191219
));
12201220
collect_alloc(tcx, alloc_id, output)
12211221
}
1222-
GlobalAlloc::Type { .. } => {}
1222+
GlobalAlloc::TypeId { .. } => {}
12231223
}
12241224
}
12251225

compiler/rustc_passes/src/reachable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ impl<'tcx> ReachableContext<'tcx> {
325325
self.visit(args);
326326
}
327327
}
328-
GlobalAlloc::Type { ty, .. } => self.visit(ty),
328+
GlobalAlloc::TypeId { ty, .. } => self.visit(ty),
329329
GlobalAlloc::Memory(alloc) => self.propagate_from_alloc(alloc),
330330
}
331331
}

compiler/rustc_smir/src/rustc_smir/convert/mir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl<'tcx> Stable<'tcx> for mir::interpret::GlobalAlloc<'tcx> {
753753
GlobalAlloc::Static(tables.static_def(*def))
754754
}
755755
mir::interpret::GlobalAlloc::Memory(alloc) => GlobalAlloc::Memory(alloc.stable(tables)),
756-
mir::interpret::GlobalAlloc::Type { .. } => todo!(),
756+
mir::interpret::GlobalAlloc::TypeId { .. } => todo!(),
757757
}
758758
}
759759
}

0 commit comments

Comments
 (0)