consistently use VTable over Vtable (matching stable stdlib API RawWakerVTable)
This commit is contained in:
parent
114da84996
commit
3dad266f40
@ -197,7 +197,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||
let (alloc_id, offset) = ptr.into_parts(); // we know the `offset` is relative
|
||||
// For vtables, get the underlying data allocation.
|
||||
let alloc_id = match fx.tcx.global_alloc(alloc_id) {
|
||||
GlobalAlloc::Vtable(ty, trait_ref) => fx.tcx.vtable_allocation((ty, trait_ref)),
|
||||
GlobalAlloc::VTable(ty, trait_ref) => fx.tcx.vtable_allocation((ty, trait_ref)),
|
||||
_ => alloc_id,
|
||||
};
|
||||
let base_addr = match fx.tcx.global_alloc(alloc_id) {
|
||||
@ -221,7 +221,7 @@ pub(crate) fn codegen_const_value<'tcx>(
|
||||
fx.module.declare_func_in_func(func_id, &mut fx.bcx.func);
|
||||
fx.bcx.ins().func_addr(fx.pointer_type, local_func_id)
|
||||
}
|
||||
GlobalAlloc::Vtable(..) => bug!("vtables are already handled"),
|
||||
GlobalAlloc::VTable(..) => bug!("vtables are already handled"),
|
||||
GlobalAlloc::Static(def_id) => {
|
||||
assert!(fx.tcx.is_static(def_id));
|
||||
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
|
||||
//println!("alloc_id {}", alloc_id);
|
||||
let alloc = match tcx.global_alloc(alloc_id) {
|
||||
GlobalAlloc::Memory(alloc) => alloc,
|
||||
GlobalAlloc::Function(_) | GlobalAlloc::Static(_) | GlobalAlloc::Vtable(..) => {
|
||||
GlobalAlloc::Function(_) | GlobalAlloc::Static(_) | GlobalAlloc::VTable(..) => {
|
||||
unreachable!()
|
||||
}
|
||||
};
|
||||
@ -442,7 +442,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
|
||||
GlobalAlloc::Memory(target_alloc) => {
|
||||
data_id_for_alloc_id(cx, module, alloc_id, target_alloc.inner().mutability)
|
||||
}
|
||||
GlobalAlloc::Vtable(ty, trait_ref) => {
|
||||
GlobalAlloc::VTable(ty, trait_ref) => {
|
||||
let alloc_id = tcx.vtable_allocation((ty, trait_ref));
|
||||
data_id_for_alloc_id(cx, module, alloc_id, Mutability::Not)
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||
let (alloc_id, offset) = ptr.into_parts();
|
||||
// For vtables, get the underlying data allocation.
|
||||
let alloc_id = match self.tcx.global_alloc(alloc_id) {
|
||||
GlobalAlloc::Vtable(ty, trait_ref) => {
|
||||
GlobalAlloc::VTable(ty, trait_ref) => {
|
||||
self.tcx.vtable_allocation((ty, trait_ref))
|
||||
}
|
||||
_ => alloc_id,
|
||||
@ -208,7 +208,7 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||
GlobalAlloc::Function(fn_instance) => {
|
||||
self.get_fn_addr(fn_instance)
|
||||
},
|
||||
GlobalAlloc::Vtable(..) => panic!("vtables are already handled"),
|
||||
GlobalAlloc::VTable(..) => panic!("vtables are already handled"),
|
||||
GlobalAlloc::Static(def_id) => {
|
||||
assert!(self.tcx.is_static(def_id));
|
||||
self.get_static(def_id).get_address(None)
|
||||
|
@ -242,7 +242,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
let (alloc_id, offset) = ptr.into_parts();
|
||||
// For vtables, get the underlying data allocation.
|
||||
let alloc_id = match self.tcx.global_alloc(alloc_id) {
|
||||
GlobalAlloc::Vtable(ty, trait_ref) => {
|
||||
GlobalAlloc::VTable(ty, trait_ref) => {
|
||||
self.tcx.vtable_allocation((ty, trait_ref))
|
||||
}
|
||||
_ => alloc_id,
|
||||
@ -264,7 +264,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||
self.get_fn_addr(fn_instance.polymorphize(self.tcx)),
|
||||
self.data_layout().instruction_address_space,
|
||||
),
|
||||
GlobalAlloc::Vtable(..) => bug!("vtables are already handled"),
|
||||
GlobalAlloc::VTable(..) => bug!("vtables are already handled"),
|
||||
GlobalAlloc::Static(def_id) => {
|
||||
assert!(self.tcx.is_static(def_id));
|
||||
assert!(!self.tcx.is_thread_local_static(def_id));
|
||||
|
@ -101,7 +101,7 @@ pub fn const_alloc_to_llvm<'ll>(cx: &CodegenCx<'ll, '_>, alloc: ConstAllocation<
|
||||
|
||||
let address_space = match cx.tcx.global_alloc(alloc_id) {
|
||||
GlobalAlloc::Function(..) => cx.data_layout().instruction_address_space,
|
||||
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::Vtable(..) => {
|
||||
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::VTable(..) => {
|
||||
AddressSpace::DATA
|
||||
}
|
||||
};
|
||||
|
@ -1420,7 +1420,7 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
|
||||
cx,
|
||||
type_map::stub(
|
||||
cx,
|
||||
Stub::VtableTy { vtable_holder },
|
||||
Stub::VTableTy { vtable_holder },
|
||||
unique_type_id,
|
||||
&vtable_type_name,
|
||||
(size, pointer_align),
|
||||
|
@ -146,7 +146,7 @@ impl<'ll> DINodeCreationResult<'ll> {
|
||||
pub enum Stub<'ll> {
|
||||
Struct,
|
||||
Union,
|
||||
VtableTy { vtable_holder: &'ll DIType },
|
||||
VTableTy { vtable_holder: &'ll DIType },
|
||||
}
|
||||
|
||||
pub struct StubInfo<'ll, 'tcx> {
|
||||
@ -180,9 +180,9 @@ pub(super) fn stub<'ll, 'tcx>(
|
||||
let unique_type_id_str = unique_type_id.generate_unique_id_string(cx.tcx);
|
||||
|
||||
let metadata = match kind {
|
||||
Stub::Struct | Stub::VtableTy { .. } => {
|
||||
Stub::Struct | Stub::VTableTy { .. } => {
|
||||
let vtable_holder = match kind {
|
||||
Stub::VtableTy { vtable_holder } => Some(vtable_holder),
|
||||
Stub::VTableTy { vtable_holder } => Some(vtable_holder),
|
||||
_ => None,
|
||||
};
|
||||
unsafe {
|
||||
|
@ -171,7 +171,7 @@ pub fn unsized_info<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
);
|
||||
let new_vptr = bx.load(ptr_ty, gep, ptr_align);
|
||||
bx.nonnull_metadata(new_vptr);
|
||||
// Vtable loads are invariant.
|
||||
// VTable loads are invariant.
|
||||
bx.set_invariant_load(new_vptr);
|
||||
new_vptr
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||
let gep = bx.inbounds_gep(llty, llvtable, &[bx.const_usize(self.0)]);
|
||||
let ptr = bx.load(llty, gep, ptr_align);
|
||||
bx.nonnull_metadata(ptr);
|
||||
// Vtable loads are invariant.
|
||||
// VTable loads are invariant.
|
||||
bx.set_invariant_load(ptr);
|
||||
ptr
|
||||
}
|
||||
@ -58,7 +58,7 @@ impl<'a, 'tcx> VirtualIndex {
|
||||
let usize_align = bx.tcx().data_layout.pointer_align.abi;
|
||||
let gep = bx.inbounds_gep(llty, llvtable, &[bx.const_usize(self.0)]);
|
||||
let ptr = bx.load(llty, gep, usize_align);
|
||||
// Vtable loads are invariant.
|
||||
// VTable loads are invariant.
|
||||
bx.set_invariant_load(ptr);
|
||||
ptr
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ pub enum AllocKind {
|
||||
/// A function allocation (that fn ptrs point to).
|
||||
Function,
|
||||
/// A (symbolic) vtable allocation.
|
||||
Vtable,
|
||||
VTable,
|
||||
/// A dead allocation.
|
||||
Dead,
|
||||
}
|
||||
@ -293,7 +293,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
Some(GlobalAlloc::Function(..)) => {
|
||||
err_ub_format!("deallocating {alloc_id:?}, which is a function")
|
||||
}
|
||||
Some(GlobalAlloc::Vtable(..)) => {
|
||||
Some(GlobalAlloc::VTable(..)) => {
|
||||
err_ub_format!("deallocating {alloc_id:?}, which is a vtable")
|
||||
}
|
||||
Some(GlobalAlloc::Static(..) | GlobalAlloc::Memory(..)) => {
|
||||
@ -484,7 +484,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
(mem, None)
|
||||
}
|
||||
Some(GlobalAlloc::Function(..)) => throw_ub!(DerefFunctionPointer(id)),
|
||||
Some(GlobalAlloc::Vtable(..)) => throw_ub!(DerefVtablePointer(id)),
|
||||
Some(GlobalAlloc::VTable(..)) => throw_ub!(DerefVTablePointer(id)),
|
||||
None => throw_ub!(PointerUseAfterFree(id)),
|
||||
Some(GlobalAlloc::Static(def_id)) => {
|
||||
assert!(self.tcx.is_static(def_id));
|
||||
@ -688,9 +688,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
(alloc.size(), alloc.align, AllocKind::LiveData)
|
||||
}
|
||||
Some(GlobalAlloc::Function(_)) => bug!("We already checked function pointers above"),
|
||||
Some(GlobalAlloc::Vtable(..)) => {
|
||||
Some(GlobalAlloc::VTable(..)) => {
|
||||
// No data to be accessed here. But vtables are pointer-aligned.
|
||||
return (Size::ZERO, self.tcx.data_layout.pointer_align.abi, AllocKind::Vtable);
|
||||
return (Size::ZERO, self.tcx.data_layout.pointer_align.abi, AllocKind::VTable);
|
||||
}
|
||||
// The rest must be dead.
|
||||
None => {
|
||||
@ -746,11 +746,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
trace!("get_ptr_vtable({:?})", ptr);
|
||||
let (alloc_id, offset, _tag) = self.ptr_get_alloc_id(ptr)?;
|
||||
if offset.bytes() != 0 {
|
||||
throw_ub!(InvalidVtablePointer(Pointer::new(alloc_id, offset)))
|
||||
throw_ub!(InvalidVTablePointer(Pointer::new(alloc_id, offset)))
|
||||
}
|
||||
match self.tcx.try_get_global_alloc(alloc_id) {
|
||||
Some(GlobalAlloc::Vtable(ty, trait_ref)) => Ok((ty, trait_ref)),
|
||||
_ => throw_ub!(InvalidVtablePointer(Pointer::new(alloc_id, offset))),
|
||||
Some(GlobalAlloc::VTable(ty, trait_ref)) => Ok((ty, trait_ref)),
|
||||
_ => throw_ub!(InvalidVTablePointer(Pointer::new(alloc_id, offset))),
|
||||
}
|
||||
}
|
||||
|
||||
@ -871,10 +871,10 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> std::fmt::Debug for DumpAllocs<'a,
|
||||
Some(GlobalAlloc::Function(func)) => {
|
||||
write!(fmt, " (fn: {func})")?;
|
||||
}
|
||||
Some(GlobalAlloc::Vtable(ty, Some(trait_ref))) => {
|
||||
Some(GlobalAlloc::VTable(ty, Some(trait_ref))) => {
|
||||
write!(fmt, " (vtable: impl {trait_ref} for {ty})")?;
|
||||
}
|
||||
Some(GlobalAlloc::Vtable(ty, None)) => {
|
||||
Some(GlobalAlloc::VTable(ty, None)) => {
|
||||
write!(fmt, " (vtable: impl <auto trait> for {ty})")?;
|
||||
}
|
||||
Some(GlobalAlloc::Static(did)) => {
|
||||
|
@ -364,7 +364,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
// caller_fn_abi is not relevant here, we interpret the arguments directly for each intrinsic.
|
||||
M::call_intrinsic(self, instance, args, destination, target, unwind)
|
||||
}
|
||||
ty::InstanceDef::VtableShim(..)
|
||||
ty::InstanceDef::VTableShim(..)
|
||||
| ty::InstanceDef::ReifyShim(..)
|
||||
| ty::InstanceDef::ClosureOnceShim { .. }
|
||||
| ty::InstanceDef::FnPtrShim(..)
|
||||
|
@ -318,7 +318,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
|
||||
self.ecx.get_ptr_vtable(vtable),
|
||||
self.path,
|
||||
err_ub!(DanglingIntPointer(..)) |
|
||||
err_ub!(InvalidVtablePointer(..)) =>
|
||||
err_ub!(InvalidVTablePointer(..)) =>
|
||||
{ "{vtable}" } expected { "a vtable pointer" },
|
||||
);
|
||||
// FIXME: check if the type/trait match what ty::Dynamic says?
|
||||
|
@ -266,7 +266,7 @@ pub enum UndefinedBehaviorInfo {
|
||||
// Trying to access the data behind a function pointer.
|
||||
DerefFunctionPointer(AllocId),
|
||||
// Trying to access the data behind a vtable pointer.
|
||||
DerefVtablePointer(AllocId),
|
||||
DerefVTablePointer(AllocId),
|
||||
/// The value validity check found a problem.
|
||||
/// Should only be thrown by `validity.rs` and always point out which part of the value
|
||||
/// is the problem.
|
||||
@ -285,7 +285,7 @@ pub enum UndefinedBehaviorInfo {
|
||||
/// Using a pointer-not-to-a-function as function pointer.
|
||||
InvalidFunctionPointer(Pointer),
|
||||
/// Using a pointer-not-to-a-vtable as vtable pointer.
|
||||
InvalidVtablePointer(Pointer),
|
||||
InvalidVTablePointer(Pointer),
|
||||
/// Using a string that is not valid UTF-8,
|
||||
InvalidStr(std::str::Utf8Error),
|
||||
/// Using uninitialized data where it is not allowed.
|
||||
@ -349,7 +349,7 @@ impl fmt::Display for UndefinedBehaviorInfo {
|
||||
),
|
||||
WriteToReadOnly(a) => write!(f, "writing to {a:?} which is read-only"),
|
||||
DerefFunctionPointer(a) => write!(f, "accessing {a:?} which contains a function"),
|
||||
DerefVtablePointer(a) => write!(f, "accessing {a:?} which contains a vtable"),
|
||||
DerefVTablePointer(a) => write!(f, "accessing {a:?} which contains a vtable"),
|
||||
ValidationFailure { path: None, msg } => {
|
||||
write!(f, "constructing invalid value: {msg}")
|
||||
}
|
||||
@ -366,7 +366,7 @@ impl fmt::Display for UndefinedBehaviorInfo {
|
||||
InvalidFunctionPointer(p) => {
|
||||
write!(f, "using {p:?} as function pointer but it does not point to a function")
|
||||
}
|
||||
InvalidVtablePointer(p) => {
|
||||
InvalidVTablePointer(p) => {
|
||||
write!(f, "using {p:?} as vtable pointer but it does not point to a vtable")
|
||||
}
|
||||
InvalidStr(err) => write!(f, "this string is not valid UTF-8: {err}"),
|
||||
|
@ -196,7 +196,7 @@ impl fmt::Debug for AllocId {
|
||||
enum AllocDiscriminant {
|
||||
Alloc,
|
||||
Fn,
|
||||
Vtable,
|
||||
VTable,
|
||||
Static,
|
||||
}
|
||||
|
||||
@ -216,9 +216,9 @@ pub fn specialized_encode_alloc_id<'tcx, E: TyEncoder<I = TyCtxt<'tcx>>>(
|
||||
AllocDiscriminant::Fn.encode(encoder);
|
||||
fn_instance.encode(encoder);
|
||||
}
|
||||
GlobalAlloc::Vtable(ty, poly_trait_ref) => {
|
||||
GlobalAlloc::VTable(ty, poly_trait_ref) => {
|
||||
trace!("encoding {:?} with {ty:#?}, {poly_trait_ref:#?}", alloc_id);
|
||||
AllocDiscriminant::Vtable.encode(encoder);
|
||||
AllocDiscriminant::VTable.encode(encoder);
|
||||
ty.encode(encoder);
|
||||
poly_trait_ref.encode(encoder);
|
||||
}
|
||||
@ -314,7 +314,7 @@ impl<'s> AllocDecodingSession<'s> {
|
||||
}
|
||||
AllocDiscriminant::Fn
|
||||
| AllocDiscriminant::Static
|
||||
| AllocDiscriminant::Vtable => {
|
||||
| AllocDiscriminant::VTable => {
|
||||
// Fns and statics cannot be cyclic, and their `AllocId`
|
||||
// is determined later by interning.
|
||||
*entry =
|
||||
@ -364,7 +364,7 @@ impl<'s> AllocDecodingSession<'s> {
|
||||
let alloc_id = decoder.interner().create_fn_alloc(instance);
|
||||
alloc_id
|
||||
}
|
||||
AllocDiscriminant::Vtable => {
|
||||
AllocDiscriminant::VTable => {
|
||||
assert!(alloc_id.is_none());
|
||||
trace!("creating static alloc ID");
|
||||
let ty = <Ty<'_> as Decodable<D>>::decode(decoder);
|
||||
@ -400,7 +400,7 @@ pub enum GlobalAlloc<'tcx> {
|
||||
/// The alloc ID is used as a function pointer.
|
||||
Function(Instance<'tcx>),
|
||||
/// This alloc ID points to a symbolic (not-reified) vtable.
|
||||
Vtable(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>),
|
||||
VTable(Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>),
|
||||
/// The alloc ID points to a "lazy" static variable that did not get computed (yet).
|
||||
/// This is also used to break the cycle in recursive statics.
|
||||
Static(DefId),
|
||||
@ -429,12 +429,12 @@ impl<'tcx> GlobalAlloc<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Panics if the `GlobalAlloc` is not `GlobalAlloc::Vtable`
|
||||
/// Panics if the `GlobalAlloc` is not `GlobalAlloc::VTable`
|
||||
#[track_caller]
|
||||
#[inline]
|
||||
pub fn unwrap_vtable(&self) -> (Ty<'tcx>, Option<ty::PolyExistentialTraitRef<'tcx>>) {
|
||||
match *self {
|
||||
GlobalAlloc::Vtable(ty, poly_trait_ref) => (ty, poly_trait_ref),
|
||||
GlobalAlloc::VTable(ty, poly_trait_ref) => (ty, poly_trait_ref),
|
||||
_ => bug!("expected vtable, got {:?}", self),
|
||||
}
|
||||
}
|
||||
@ -490,7 +490,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
fn reserve_and_set_dedup(self, alloc: GlobalAlloc<'tcx>) -> AllocId {
|
||||
let mut alloc_map = self.alloc_map.lock();
|
||||
match alloc {
|
||||
GlobalAlloc::Function(..) | GlobalAlloc::Static(..) | GlobalAlloc::Vtable(..) => {}
|
||||
GlobalAlloc::Function(..) | GlobalAlloc::Static(..) | GlobalAlloc::VTable(..) => {}
|
||||
GlobalAlloc::Memory(..) => bug!("Trying to dedup-reserve memory with real data!"),
|
||||
}
|
||||
if let Some(&alloc_id) = alloc_map.dedup.get(&alloc) {
|
||||
@ -541,7 +541,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
ty: Ty<'tcx>,
|
||||
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
|
||||
) -> AllocId {
|
||||
self.reserve_and_set_dedup(GlobalAlloc::Vtable(ty, poly_trait_ref))
|
||||
self.reserve_and_set_dedup(GlobalAlloc::VTable(ty, poly_trait_ref))
|
||||
}
|
||||
|
||||
/// Interns the `Allocation` and return a new `AllocId`, even if there's already an identical
|
||||
|
@ -362,7 +362,7 @@ impl<'tcx> CodegenUnit<'tcx> {
|
||||
// the codegen tests and can even make item order
|
||||
// unstable.
|
||||
InstanceDef::Item(def) => def.did.as_local().map(Idx::index),
|
||||
InstanceDef::VtableShim(..)
|
||||
InstanceDef::VTableShim(..)
|
||||
| InstanceDef::ReifyShim(..)
|
||||
| InstanceDef::Intrinsic(..)
|
||||
| InstanceDef::FnPtrShim(..)
|
||||
|
@ -725,10 +725,12 @@ pub fn write_allocations<'tcx>(
|
||||
// gracefully handle it and allow buggy rustc to be debugged via allocation printing.
|
||||
None => write!(w, " (deallocated)")?,
|
||||
Some(GlobalAlloc::Function(inst)) => write!(w, " (fn: {inst})")?,
|
||||
Some(GlobalAlloc::Vtable(ty, Some(trait_ref))) => {
|
||||
Some(GlobalAlloc::VTable(ty, Some(trait_ref))) => {
|
||||
write!(w, " (vtable: impl {trait_ref} for {ty})")?
|
||||
}
|
||||
Some(GlobalAlloc::Vtable(ty, None)) => write!(w, " (vtable: impl <auto trait> for {ty})")?,
|
||||
Some(GlobalAlloc::VTable(ty, None)) => {
|
||||
write!(w, " (vtable: impl <auto trait> for {ty})")?
|
||||
}
|
||||
Some(GlobalAlloc::Static(did)) if !tcx.is_foreign_item(did) => {
|
||||
match tcx.eval_static_initializer(did) {
|
||||
Ok(alloc) => {
|
||||
|
@ -394,7 +394,7 @@ macro_rules! make_mir_visitor {
|
||||
ty::InstanceDef::Item(_def_id) => {}
|
||||
|
||||
ty::InstanceDef::Intrinsic(_def_id) |
|
||||
ty::InstanceDef::VtableShim(_def_id) |
|
||||
ty::InstanceDef::VTableShim(_def_id) |
|
||||
ty::InstanceDef::ReifyShim(_def_id) |
|
||||
ty::InstanceDef::Virtual(_def_id, _) |
|
||||
ty::InstanceDef::ClosureOnceShim { call_once: _def_id, track_caller: _ } |
|
||||
|
@ -49,7 +49,7 @@ pub enum InstanceDef<'tcx> {
|
||||
///
|
||||
/// The generated shim will take `Self` via `*mut Self` - conceptually this is `&owned Self` -
|
||||
/// and dereference the argument to call the original function.
|
||||
VtableShim(DefId),
|
||||
VTableShim(DefId),
|
||||
|
||||
/// `fn()` pointer where the function itself cannot be turned into a pointer.
|
||||
///
|
||||
@ -145,7 +145,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||
pub fn def_id(self) -> DefId {
|
||||
match self {
|
||||
InstanceDef::Item(def) => def.did,
|
||||
InstanceDef::VtableShim(def_id)
|
||||
InstanceDef::VTableShim(def_id)
|
||||
| InstanceDef::ReifyShim(def_id)
|
||||
| InstanceDef::FnPtrShim(def_id, _)
|
||||
| InstanceDef::Virtual(def_id, _)
|
||||
@ -161,7 +161,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||
match self {
|
||||
ty::InstanceDef::Item(def) => Some(def.did),
|
||||
ty::InstanceDef::DropGlue(def_id, Some(_)) => Some(def_id),
|
||||
InstanceDef::VtableShim(..)
|
||||
InstanceDef::VTableShim(..)
|
||||
| InstanceDef::ReifyShim(..)
|
||||
| InstanceDef::FnPtrShim(..)
|
||||
| InstanceDef::Virtual(..)
|
||||
@ -176,7 +176,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||
pub fn with_opt_param(self) -> ty::WithOptConstParam<DefId> {
|
||||
match self {
|
||||
InstanceDef::Item(def) => def,
|
||||
InstanceDef::VtableShim(def_id)
|
||||
InstanceDef::VTableShim(def_id)
|
||||
| InstanceDef::ReifyShim(def_id)
|
||||
| InstanceDef::FnPtrShim(def_id, _)
|
||||
| InstanceDef::Virtual(def_id, _)
|
||||
@ -273,7 +273,7 @@ impl<'tcx> InstanceDef<'tcx> {
|
||||
| InstanceDef::Intrinsic(..)
|
||||
| InstanceDef::ReifyShim(..)
|
||||
| InstanceDef::Virtual(..)
|
||||
| InstanceDef::VtableShim(..) => true,
|
||||
| InstanceDef::VTableShim(..) => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -290,7 +290,7 @@ impl<'tcx> fmt::Display for Instance<'tcx> {
|
||||
|
||||
match self.def {
|
||||
InstanceDef::Item(_) => Ok(()),
|
||||
InstanceDef::VtableShim(_) => write!(f, " - shim(vtable)"),
|
||||
InstanceDef::VTableShim(_) => write!(f, " - shim(vtable)"),
|
||||
InstanceDef::ReifyShim(_) => write!(f, " - shim(reify)"),
|
||||
InstanceDef::Intrinsic(_) => write!(f, " - intrinsic"),
|
||||
InstanceDef::Virtual(_, num) => write!(f, " - virtual#{}", num),
|
||||
@ -434,7 +434,7 @@ impl<'tcx> Instance<'tcx> {
|
||||
&& tcx.generics_of(def_id).has_self;
|
||||
if is_vtable_shim {
|
||||
debug!(" => associated item with unsizeable self: Self");
|
||||
Some(Instance { def: InstanceDef::VtableShim(def_id), substs })
|
||||
Some(Instance { def: InstanceDef::VTableShim(def_id), substs })
|
||||
} else {
|
||||
Instance::resolve(tcx, param_env, def_id, substs).ok().flatten().map(|mut resolved| {
|
||||
match resolved.def {
|
||||
|
@ -2771,7 +2771,7 @@ impl<'tcx> ty::Instance<'tcx> {
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
if let ty::InstanceDef::VtableShim(..) = self.def {
|
||||
if let ty::InstanceDef::VTableShim(..) = self.def {
|
||||
// Modify `fn(self, ...)` to `fn(self: *mut Self, ...)`.
|
||||
sig = sig.map_bound(|mut sig| {
|
||||
let mut inputs_and_output = sig.inputs_and_output.to_vec();
|
||||
|
@ -2135,7 +2135,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
}
|
||||
ty::InstanceDef::VtableShim(..)
|
||||
ty::InstanceDef::VTableShim(..)
|
||||
| ty::InstanceDef::ReifyShim(..)
|
||||
| ty::InstanceDef::Intrinsic(..)
|
||||
| ty::InstanceDef::FnPtrShim(..)
|
||||
|
@ -1287,7 +1287,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
p!(write("<static({:?})>", def_id))
|
||||
}
|
||||
Some(GlobalAlloc::Function(_)) => p!("<function>"),
|
||||
Some(GlobalAlloc::Vtable(..)) => p!("<vtable>"),
|
||||
Some(GlobalAlloc::VTable(..)) => p!("<vtable>"),
|
||||
None => p!("<dangling pointer>"),
|
||||
}
|
||||
return Ok(self);
|
||||
|
@ -624,7 +624,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::InstanceDef<'a> {
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
match self {
|
||||
ty::InstanceDef::Item(def_id) => Some(ty::InstanceDef::Item(def_id)),
|
||||
ty::InstanceDef::VtableShim(def_id) => Some(ty::InstanceDef::VtableShim(def_id)),
|
||||
ty::InstanceDef::VTableShim(def_id) => Some(ty::InstanceDef::VTableShim(def_id)),
|
||||
ty::InstanceDef::ReifyShim(def_id) => Some(ty::InstanceDef::ReifyShim(def_id)),
|
||||
ty::InstanceDef::Intrinsic(def_id) => Some(ty::InstanceDef::Intrinsic(def_id)),
|
||||
ty::InstanceDef::FnPtrShim(def_id, ty) => {
|
||||
@ -927,7 +927,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> {
|
||||
substs: self.substs.try_fold_with(folder)?,
|
||||
def: match self.def {
|
||||
Item(def) => Item(def.try_fold_with(folder)?),
|
||||
VtableShim(did) => VtableShim(did.try_fold_with(folder)?),
|
||||
VTableShim(did) => VTableShim(did.try_fold_with(folder)?),
|
||||
ReifyShim(did) => ReifyShim(did.try_fold_with(folder)?),
|
||||
Intrinsic(did) => Intrinsic(did.try_fold_with(folder)?),
|
||||
FnPtrShim(did, ty) => {
|
||||
@ -954,7 +954,7 @@ impl<'tcx> TypeVisitable<'tcx> for ty::instance::Instance<'tcx> {
|
||||
self.substs.visit_with(visitor)?;
|
||||
match self.def {
|
||||
Item(def) => def.visit_with(visitor),
|
||||
VtableShim(did) | ReifyShim(did) | Intrinsic(did) | Virtual(did, _) => {
|
||||
VTableShim(did) | ReifyShim(did) | Intrinsic(did) | Virtual(did, _) => {
|
||||
did.visit_with(visitor)
|
||||
}
|
||||
FnPtrShim(did, ty) | CloneShim(did, ty) => {
|
||||
|
@ -246,7 +246,7 @@ impl<'tcx> Inliner<'tcx> {
|
||||
// not get any optimizations run on it. Any subsequent inlining may cause cycles, but we
|
||||
// do not need to catch this here, we can wait until the inliner decides to continue
|
||||
// inlining a second time.
|
||||
InstanceDef::VtableShim(_)
|
||||
InstanceDef::VTableShim(_)
|
||||
| InstanceDef::ReifyShim(_)
|
||||
| InstanceDef::FnPtrShim(..)
|
||||
| InstanceDef::ClosureOnceShim { .. }
|
||||
|
@ -79,7 +79,7 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
|
||||
// These have MIR and if that MIR is inlined, substituted and then inlining is run
|
||||
// again, a function item can end up getting inlined. Thus we'll be able to cause
|
||||
// a cycle that way
|
||||
InstanceDef::VtableShim(_)
|
||||
InstanceDef::VTableShim(_)
|
||||
| InstanceDef::ReifyShim(_)
|
||||
| InstanceDef::FnPtrShim(..)
|
||||
| InstanceDef::ClosureOnceShim { .. }
|
||||
|
@ -32,7 +32,7 @@ fn make_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: ty::InstanceDef<'tcx>) -> Body<'
|
||||
|
||||
let mut result = match instance {
|
||||
ty::InstanceDef::Item(..) => bug!("item {:?} passed to make_shim", instance),
|
||||
ty::InstanceDef::VtableShim(def_id) => {
|
||||
ty::InstanceDef::VTableShim(def_id) => {
|
||||
build_call_shim(tcx, instance, Some(Adjustment::Deref), CallKind::Direct(def_id))
|
||||
}
|
||||
ty::InstanceDef::FnPtrShim(def_id, ty) => {
|
||||
@ -113,7 +113,7 @@ enum Adjustment {
|
||||
/// We get passed `&[mut] self` and call the target with `*self`.
|
||||
///
|
||||
/// This either copies `self` (if `Self: Copy`, eg. for function items), or moves out of it
|
||||
/// (for `VtableShim`, which effectively is passed `&own Self`).
|
||||
/// (for `VTableShim`, which effectively is passed `&own Self`).
|
||||
Deref,
|
||||
|
||||
/// We get passed `self: Self` and call the target with `&mut self`.
|
||||
@ -569,7 +569,7 @@ fn build_call_shim<'tcx>(
|
||||
|
||||
// FIXME(eddyb) avoid having this snippet both here and in
|
||||
// `Instance::fn_sig` (introduce `InstanceDef::fn_sig`?).
|
||||
if let ty::InstanceDef::VtableShim(..) = instance {
|
||||
if let ty::InstanceDef::VTableShim(..) = instance {
|
||||
// Modify fn(self, ...) to fn(self: *mut Self, ...)
|
||||
let mut inputs_and_output = sig.inputs_and_output.to_vec();
|
||||
let self_arg = &mut inputs_and_output[0];
|
||||
|
@ -25,7 +25,7 @@
|
||||
//! codegen unit:
|
||||
//!
|
||||
//! - Constants
|
||||
//! - Vtables
|
||||
//! - VTables
|
||||
//! - Object Shims
|
||||
//!
|
||||
//!
|
||||
@ -992,7 +992,7 @@ fn visit_instance_use<'tcx>(
|
||||
}
|
||||
}
|
||||
ty::InstanceDef::DropGlue(_, Some(_))
|
||||
| ty::InstanceDef::VtableShim(..)
|
||||
| ty::InstanceDef::VTableShim(..)
|
||||
| ty::InstanceDef::ReifyShim(..)
|
||||
| ty::InstanceDef::ClosureOnceShim { .. }
|
||||
| ty::InstanceDef::Item(..)
|
||||
@ -1427,7 +1427,7 @@ fn collect_miri<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIte
|
||||
output.push(create_fn_mono_item(tcx, fn_instance, DUMMY_SP));
|
||||
}
|
||||
}
|
||||
GlobalAlloc::Vtable(ty, trait_ref) => {
|
||||
GlobalAlloc::VTable(ty, trait_ref) => {
|
||||
// FIXME(RJ) no ideas if this is correct. There is this nice
|
||||
// `create_mono_items_for_vtable_methods` method but I wouldn't know how to call it from
|
||||
// here. So instead we just generate the actual vtable and recurse.
|
||||
|
@ -271,7 +271,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
|
||||
MonoItem::Fn(instance) => {
|
||||
let def_id = match instance.def {
|
||||
ty::InstanceDef::Item(def) => def.did,
|
||||
ty::InstanceDef::VtableShim(..)
|
||||
ty::InstanceDef::VTableShim(..)
|
||||
| ty::InstanceDef::ReifyShim(..)
|
||||
| ty::InstanceDef::FnPtrShim(..)
|
||||
| ty::InstanceDef::ClosureOnceShim { .. }
|
||||
@ -425,7 +425,7 @@ fn mono_item_visibility<'tcx>(
|
||||
InstanceDef::DropGlue(def_id, Some(_)) => def_id,
|
||||
|
||||
// These are all compiler glue and such, never exported, always hidden.
|
||||
InstanceDef::VtableShim(..)
|
||||
InstanceDef::VTableShim(..)
|
||||
| InstanceDef::ReifyShim(..)
|
||||
| InstanceDef::FnPtrShim(..)
|
||||
| InstanceDef::Virtual(..)
|
||||
|
@ -37,7 +37,7 @@ mod values;
|
||||
use self::values::Value;
|
||||
|
||||
pub use rustc_query_system::query::QueryConfig;
|
||||
pub(crate) use rustc_query_system::query::{QueryDescription, QueryVtable};
|
||||
pub(crate) use rustc_query_system::query::{QueryDescription, QueryVTable};
|
||||
|
||||
mod on_disk_cache;
|
||||
pub use on_disk_cache::OnDiskCache;
|
||||
|
@ -340,11 +340,11 @@ macro_rules! define_queries {
|
||||
|
||||
#[inline]
|
||||
fn make_vtable(tcx: QueryCtxt<'tcx>, key: &Self::Key) ->
|
||||
QueryVtable<QueryCtxt<$tcx>, Self::Key, Self::Value>
|
||||
QueryVTable<QueryCtxt<$tcx>, Self::Key, Self::Value>
|
||||
{
|
||||
let compute = get_provider!([$($modifiers)*][tcx, $name, key]);
|
||||
let cache_on_disk = Self::cache_on_disk(tcx.tcx, key);
|
||||
QueryVtable {
|
||||
QueryVTable {
|
||||
anon: is_anon!([$($modifiers)*]),
|
||||
eval_always: is_eval_always!([$($modifiers)*]),
|
||||
dep_kind: dep_graph::DepKind::$name,
|
||||
|
@ -19,7 +19,7 @@ pub trait QueryConfig {
|
||||
type Stored: Clone;
|
||||
}
|
||||
|
||||
pub struct QueryVtable<CTX: QueryContext, K, V> {
|
||||
pub struct QueryVTable<CTX: QueryContext, K, V> {
|
||||
pub anon: bool,
|
||||
pub dep_kind: CTX::DepKind,
|
||||
pub eval_always: bool,
|
||||
@ -31,7 +31,7 @@ pub struct QueryVtable<CTX: QueryContext, K, V> {
|
||||
pub try_load_from_disk: Option<fn(CTX, SerializedDepNodeIndex) -> Option<V>>,
|
||||
}
|
||||
|
||||
impl<CTX: QueryContext, K, V> QueryVtable<CTX, K, V> {
|
||||
impl<CTX: QueryContext, K, V> QueryVTable<CTX, K, V> {
|
||||
pub(crate) fn to_dep_node(&self, tcx: CTX::DepContext, key: &K) -> DepNode<CTX::DepKind>
|
||||
where
|
||||
K: crate::dep_graph::DepNodeParams<CTX::DepContext>,
|
||||
@ -69,7 +69,7 @@ pub trait QueryDescription<CTX: QueryContext>: QueryConfig {
|
||||
CTX: 'a;
|
||||
|
||||
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
||||
fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVtable<CTX, Self::Key, Self::Value>;
|
||||
fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVTable<CTX, Self::Key, Self::Value>;
|
||||
|
||||
fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool;
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ pub use self::caches::{
|
||||
};
|
||||
|
||||
mod config;
|
||||
pub use self::config::{QueryConfig, QueryDescription, QueryVtable};
|
||||
pub use self::config::{QueryConfig, QueryDescription, QueryVTable};
|
||||
|
||||
use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use crate::dep_graph::{DepContext, DepNode, DepNodeIndex, DepNodeParams};
|
||||
use crate::query::caches::QueryCache;
|
||||
use crate::query::config::{QueryDescription, QueryVtable};
|
||||
use crate::query::config::{QueryDescription, QueryVTable};
|
||||
use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo};
|
||||
use crate::query::{QueryContext, QueryMap, QuerySideEffects, QueryStackFrame};
|
||||
use rustc_data_structures::fingerprint::Fingerprint;
|
||||
@ -331,7 +331,7 @@ fn try_execute_query<CTX, C>(
|
||||
span: Span,
|
||||
key: C::Key,
|
||||
dep_node: Option<DepNode<CTX::DepKind>>,
|
||||
query: &QueryVtable<CTX, C::Key, C::Value>,
|
||||
query: &QueryVTable<CTX, C::Key, C::Value>,
|
||||
) -> (C::Stored, Option<DepNodeIndex>)
|
||||
where
|
||||
C: QueryCache,
|
||||
@ -368,7 +368,7 @@ fn execute_job<CTX, K, V>(
|
||||
tcx: CTX,
|
||||
key: K,
|
||||
mut dep_node_opt: Option<DepNode<CTX::DepKind>>,
|
||||
query: &QueryVtable<CTX, K, V>,
|
||||
query: &QueryVTable<CTX, K, V>,
|
||||
job_id: QueryJobId,
|
||||
) -> (V, DepNodeIndex)
|
||||
where
|
||||
@ -437,7 +437,7 @@ fn try_load_from_disk_and_cache_in_memory<CTX, K, V>(
|
||||
tcx: CTX,
|
||||
key: &K,
|
||||
dep_node: &DepNode<CTX::DepKind>,
|
||||
query: &QueryVtable<CTX, K, V>,
|
||||
query: &QueryVTable<CTX, K, V>,
|
||||
) -> Option<(V, DepNodeIndex)>
|
||||
where
|
||||
K: Clone,
|
||||
@ -530,7 +530,7 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
|
||||
tcx: CTX::DepContext,
|
||||
result: &V,
|
||||
dep_node: &DepNode<CTX::DepKind>,
|
||||
query: &QueryVtable<CTX, K, V>,
|
||||
query: &QueryVTable<CTX, K, V>,
|
||||
) where
|
||||
CTX: QueryContext,
|
||||
{
|
||||
@ -642,7 +642,7 @@ fn incremental_verify_ich_cold(sess: &Session, dep_node: DebugArg<'_>, result: D
|
||||
fn ensure_must_run<CTX, K, V>(
|
||||
tcx: CTX,
|
||||
key: &K,
|
||||
query: &QueryVtable<CTX, K, V>,
|
||||
query: &QueryVTable<CTX, K, V>,
|
||||
) -> (bool, Option<DepNode<CTX::DepKind>>)
|
||||
where
|
||||
K: crate::dep_graph::DepNodeParams<CTX::DepContext>,
|
||||
|
@ -67,7 +67,7 @@ pub(super) fn mangle<'tcx>(
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
if let ty::InstanceDef::VtableShim(..) = instance.def {
|
||||
if let ty::InstanceDef::VTableShim(..) = instance.def {
|
||||
let _ = printer.write_str("{{vtable-shim}}");
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ fn get_symbol_hash<'tcx>(
|
||||
}
|
||||
|
||||
// We want to avoid accidental collision between different types of instances.
|
||||
// Especially, `VtableShim`s and `ReifyShim`s may overlap with their original
|
||||
// Especially, `VTableShim`s and `ReifyShim`s may overlap with their original
|
||||
// instances without this.
|
||||
discriminant(&instance.def).hash_stable(hcx, &mut hasher);
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ pub(super) fn mangle<'tcx>(
|
||||
|
||||
// Append `::{shim:...#0}` to shims that can coexist with a non-shim instance.
|
||||
let shim_kind = match instance.def {
|
||||
ty::InstanceDef::VtableShim(_) => Some("vtable"),
|
||||
ty::InstanceDef::VTableShim(_) => Some("vtable"),
|
||||
ty::InstanceDef::ReifyShim(_) => Some("reify"),
|
||||
|
||||
_ => None,
|
||||
|
@ -69,7 +69,7 @@ enum PointerKind<'tcx> {
|
||||
/// No metadata attached, ie pointer to sized type or foreign type
|
||||
Thin,
|
||||
/// A trait object
|
||||
Vtable(Option<DefId>),
|
||||
VTable(Option<DefId>),
|
||||
/// Slice
|
||||
Length,
|
||||
/// The unsize info of this projection
|
||||
@ -102,7 +102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
|
||||
Ok(match *t.kind() {
|
||||
ty::Slice(_) | ty::Str => Some(PointerKind::Length),
|
||||
ty::Dynamic(ref tty, ..) => Some(PointerKind::Vtable(tty.principal_def_id())),
|
||||
ty::Dynamic(ref tty, ..) => Some(PointerKind::VTable(tty.principal_def_id())),
|
||||
ty::Adt(def, substs) if def.is_struct() => match def.non_enum_variant().fields.last() {
|
||||
None => Some(PointerKind::Thin),
|
||||
Some(f) => {
|
||||
@ -951,7 +951,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
||||
match fcx.pointer_kind(m_cast.ty, self.span)? {
|
||||
None => Err(CastError::UnknownCastPtrKind),
|
||||
Some(PointerKind::Thin) => Ok(CastKind::AddrPtrCast),
|
||||
Some(PointerKind::Vtable(_)) => Err(CastError::IntToFatCast(Some("a vtable"))),
|
||||
Some(PointerKind::VTable(_)) => Err(CastError::IntToFatCast(Some("a vtable"))),
|
||||
Some(PointerKind::Length) => Err(CastError::IntToFatCast(Some("a length"))),
|
||||
Some(
|
||||
PointerKind::OfProjection(_)
|
||||
|
Loading…
x
Reference in New Issue
Block a user