Skip to content

Commit 3dad266

Browse files
committed
consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)
1 parent 114da84 commit 3dad266

File tree

34 files changed

+90
-88
lines changed

34 files changed

+90
-88
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub(crate) fn codegen_const_value<'tcx>(
197197
let (alloc_id, offset) = ptr.into_parts(); // we know the `offset` is relative
198198
// For vtables, get the underlying data allocation.
199199
let alloc_id = match fx.tcx.global_alloc(alloc_id) {
200-
GlobalAlloc::Vtable(ty, trait_ref) => fx.tcx.vtable_allocation((ty, trait_ref)),
200+
GlobalAlloc::VTable(ty, trait_ref) => fx.tcx.vtable_allocation((ty, trait_ref)),
201201
_ => alloc_id,
202202
};
203203
let base_addr = match fx.tcx.global_alloc(alloc_id) {
@@ -221,7 +221,7 @@ pub(crate) fn codegen_const_value<'tcx>(
221221
fx.module.declare_func_in_func(func_id, &mut fx.bcx.func);
222222
fx.bcx.ins().func_addr(fx.pointer_type, local_func_id)
223223
}
224-
GlobalAlloc::Vtable(..) => bug!("vtables are already handled"),
224+
GlobalAlloc::VTable(..) => bug!("vtables are already handled"),
225225
GlobalAlloc::Static(def_id) => {
226226
assert!(fx.tcx.is_static(def_id));
227227
let data_id = data_id_for_static(fx.tcx, fx.module, def_id, false);
@@ -364,7 +364,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
364364
//println!("alloc_id {}", alloc_id);
365365
let alloc = match tcx.global_alloc(alloc_id) {
366366
GlobalAlloc::Memory(alloc) => alloc,
367-
GlobalAlloc::Function(_) | GlobalAlloc::Static(_) | GlobalAlloc::Vtable(..) => {
367+
GlobalAlloc::Function(_) | GlobalAlloc::Static(_) | GlobalAlloc::VTable(..) => {
368368
unreachable!()
369369
}
370370
};
@@ -442,7 +442,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
442442
GlobalAlloc::Memory(target_alloc) => {
443443
data_id_for_alloc_id(cx, module, alloc_id, target_alloc.inner().mutability)
444444
}
445-
GlobalAlloc::Vtable(ty, trait_ref) => {
445+
GlobalAlloc::VTable(ty, trait_ref) => {
446446
let alloc_id = tcx.vtable_allocation((ty, trait_ref));
447447
data_id_for_alloc_id(cx, module, alloc_id, Mutability::Not)
448448
}

compiler/rustc_codegen_gcc/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
185185
let (alloc_id, offset) = ptr.into_parts();
186186
// For vtables, get the underlying data allocation.
187187
let alloc_id = match self.tcx.global_alloc(alloc_id) {
188-
GlobalAlloc::Vtable(ty, trait_ref) => {
188+
GlobalAlloc::VTable(ty, trait_ref) => {
189189
self.tcx.vtable_allocation((ty, trait_ref))
190190
}
191191
_ => alloc_id,
@@ -208,7 +208,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
208208
GlobalAlloc::Function(fn_instance) => {
209209
self.get_fn_addr(fn_instance)
210210
},
211-
GlobalAlloc::Vtable(..) => panic!("vtables are already handled"),
211+
GlobalAlloc::VTable(..) => panic!("vtables are already handled"),
212212
GlobalAlloc::Static(def_id) => {
213213
assert!(self.tcx.is_static(def_id));
214214
self.get_static(def_id).get_address(None)

compiler/rustc_codegen_llvm/src/common.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
242242
let (alloc_id, offset) = ptr.into_parts();
243243
// For vtables, get the underlying data allocation.
244244
let alloc_id = match self.tcx.global_alloc(alloc_id) {
245-
GlobalAlloc::Vtable(ty, trait_ref) => {
245+
GlobalAlloc::VTable(ty, trait_ref) => {
246246
self.tcx.vtable_allocation((ty, trait_ref))
247247
}
248248
_ => alloc_id,
@@ -264,7 +264,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
264264
self.get_fn_addr(fn_instance.polymorphize(self.tcx)),
265265
self.data_layout().instruction_address_space,
266266
),
267-
GlobalAlloc::Vtable(..) => bug!("vtables are already handled"),
267+
GlobalAlloc::VTable(..) => bug!("vtables are already handled"),
268268
GlobalAlloc::Static(def_id) => {
269269
assert!(self.tcx.is_static(def_id));
270270
assert!(!self.tcx.is_thread_local_static(def_id));

compiler/rustc_codegen_llvm/src/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<
101101

102102
let address_space = match cx.tcx.global_alloc(alloc_id) {
103103
GlobalAlloc::Function(..) => cx.data_layout().instruction_address_space,
104-
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::Vtable(..) => {
104+
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::VTable(..) => {
105105
AddressSpace::DATA
106106
}
107107
};

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
14201420
cx,
14211421
type_map::stub(
14221422
cx,
1423-
Stub::VtableTy { vtable_holder },
1423+
Stub::VTableTy { vtable_holder },
14241424
unique_type_id,
14251425
&vtable_type_name,
14261426
(size, pointer_align),

compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'ll> DINodeCreationResult<'ll> {
146146
pub enum Stub<'ll> {
147147
Struct,
148148
Union,
149-
VtableTy { vtable_holder: &'ll DIType },
149+
VTableTy { vtable_holder: &'ll DIType },
150150
}
151151

152152
pub struct StubInfo<'ll, 'tcx> {
@@ -180,9 +180,9 @@ pub(super) fn stub<'ll, 'tcx>(
180180
let unique_type_id_str = unique_type_id.generate_unique_id_string(cx.tcx);
181181

182182
let metadata = match kind {
183-
Stub::Struct | Stub::VtableTy { .. } => {
183+
Stub::Struct | Stub::VTableTy { .. } => {
184184
let vtable_holder = match kind {
185-
Stub::VtableTy { vtable_holder } => Some(vtable_holder),
185+
Stub::VTableTy { vtable_holder } => Some(vtable_holder),
186186
_ => None,
187187
};
188188
unsafe {

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
171171
);
172172
let new_vptr = bx.load(ptr_ty, gep, ptr_align);
173173
bx.nonnull_metadata(new_vptr);
174-
// Vtable loads are invariant.
174+
// VTable loads are invariant.
175175
bx.set_invariant_load(new_vptr);
176176
new_vptr
177177
} else {

compiler/rustc_codegen_ssa/src/meth.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl<'a, 'tcx> VirtualIndex {
3939
let gep = bx.inbounds_gep(llty, llvtable, &[bx.const_usize(self.0)]);
4040
let ptr = bx.load(llty, gep, ptr_align);
4141
bx.nonnull_metadata(ptr);
42-
// Vtable loads are invariant.
42+
// VTable loads are invariant.
4343
bx.set_invariant_load(ptr);
4444
ptr
4545
}
@@ -58,7 +58,7 @@ impl<'a, 'tcx> VirtualIndex {
5858
let usize_align = bx.tcx().data_layout.pointer_align.abi;
5959
let gep = bx.inbounds_gep(llty, llvtable, &[bx.const_usize(self.0)]);
6060
let ptr = bx.load(llty, gep, usize_align);
61-
// Vtable loads are invariant.
61+
// VTable loads are invariant.
6262
bx.set_invariant_load(ptr);
6363
ptr
6464
}

compiler/rustc_const_eval/src/interpret/memory.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub enum AllocKind {
6363
/// A function allocation (that fn ptrs point to).
6464
Function,
6565
/// A (symbolic) vtable allocation.
66-
Vtable,
66+
VTable,
6767
/// A dead allocation.
6868
Dead,
6969
}
@@ -293,7 +293,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
293293
Some(GlobalAlloc::Function(..)) => {
294294
err_ub_format!("deallocating {alloc_id:?}, which is a function")
295295
}
296-
Some(GlobalAlloc::Vtable(..)) => {
296+
Some(GlobalAlloc::VTable(..)) => {
297297
err_ub_format!("deallocating {alloc_id:?}, which is a vtable")
298298
}
299299
Some(GlobalAlloc::Static(..) | GlobalAlloc::Memory(..)) => {
@@ -484,7 +484,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
484484
(mem, None)
485485
}
486486
Some(GlobalAlloc::Function(..)) => throw_ub!(DerefFunctionPointer(id)),
487-
Some(GlobalAlloc::Vtable(..)) => throw_ub!(DerefVtablePointer(id)),
487+
Some(GlobalAlloc::VTable(..)) => throw_ub!(DerefVTablePointer(id)),
488488
None => throw_ub!(PointerUseAfterFree(id)),
489489
Some(GlobalAlloc::Static(def_id)) => {
490490
assert!(self.tcx.is_static(def_id));
@@ -688,9 +688,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
688688
(alloc.size(), alloc.align, AllocKind::LiveData)
689689
}
690690
Some(GlobalAlloc::Function(_)) => bug!("We already checked function pointers above"),
691-
Some(GlobalAlloc::Vtable(..)) => {
691+
Some(GlobalAlloc::VTable(..)) => {
692692
// No data to be accessed here. But vtables are pointer-aligned.
693-
return (Size::ZERO, self.tcx.data_layout.pointer_align.abi, AllocKind::Vtable);
693+
return (Size::ZERO, self.tcx.data_layout.pointer_align.abi, AllocKind::VTable);
694694
}
695695
// The rest must be dead.
696696
None => {
@@ -746,11 +746,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
746746
trace!("get_ptr_vtable({:?})", ptr);
747747
let (alloc_id, offset, _tag) = self.ptr_get_alloc_id(ptr)?;
748748
if offset.bytes() != 0 {
749-
throw_ub!(InvalidVtablePointer(Pointer::new(alloc_id, offset)))
749+
throw_ub!(InvalidVTablePointer(Pointer::new(alloc_id, offset)))
750750
}
751751
match self.tcx.try_get_global_alloc(alloc_id) {
752-
Some(GlobalAlloc::Vtable(ty, trait_ref)) => Ok((ty, trait_ref)),
753-
_ => throw_ub!(InvalidVtablePointer(Pointer::new(alloc_id, offset))),
752+
Some(GlobalAlloc::VTable(ty, trait_ref)) => Ok((ty, trait_ref)),
753+
_ => throw_ub!(InvalidVTablePointer(Pointer::new(alloc_id, offset))),
754754
}
755755
}
756756

@@ -871,10 +871,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
871871
Some(GlobalAlloc::Function(func)) => {
872872
write!(fmt, " (fn: {func})")?;
873873
}
874-
Some(GlobalAlloc::Vtable(ty, Some(trait_ref))) => {
874+
Some(GlobalAlloc::VTable(ty, Some(trait_ref))) => {
875875
write!(fmt, " (vtable: impl {trait_ref} for {ty})")?;
876876
}
877-
Some(GlobalAlloc::Vtable(ty, None)) => {
877+
Some(GlobalAlloc::VTable(ty, None)) => {
878878
write!(fmt, " (vtable: impl <auto trait> for {ty})")?;
879879
}
880880
Some(GlobalAlloc::Static(did)) => {

compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
364364
// caller_fn_abi is not relevant here, we interpret the arguments directly for each intrinsic.
365365
M::call_intrinsic(self, instance, args, destination, target, unwind)
366366
}
367-
ty::InstanceDef::VtableShim(..)
367+
ty::InstanceDef::VTableShim(..)
368368
| ty::InstanceDef::ReifyShim(..)
369369
| ty::InstanceDef::ClosureOnceShim { .. }
370370
| ty::InstanceDef::FnPtrShim(..)

0 commit comments

Comments
 (0)