Auto merge of #108075 - WaffleLapkin:de-arena-allocates-you-OwO, r=Nilstrieb
Remove `arena_cache` modifier from `associated_item` query & copy `ty::AssocItem` instead of passing by ref r? `@ghost`
This commit is contained in:
commit
9aa5c24b7d
18 changed files with 93 additions and 101 deletions
|
@ -97,7 +97,7 @@ fn check_is_object_safe(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
|
|||
/// object. Note that object-safe traits can have some
|
||||
/// non-vtable-safe methods, so long as they require `Self: Sized` or
|
||||
/// otherwise ensure that they cannot be used when `Self = Trait`.
|
||||
pub fn is_vtable_safe_method(tcx: TyCtxt<'_>, trait_def_id: DefId, method: &ty::AssocItem) -> bool {
|
||||
pub fn is_vtable_safe_method(tcx: TyCtxt<'_>, trait_def_id: DefId, method: ty::AssocItem) -> bool {
|
||||
debug_assert!(tcx.generics_of(trait_def_id).has_self);
|
||||
debug!("is_vtable_safe_method({:?}, {:?})", trait_def_id, method);
|
||||
// Any method that has a `Self: Sized` bound cannot be called.
|
||||
|
@ -120,8 +120,8 @@ fn object_safety_violations_for_trait(
|
|||
.associated_items(trait_def_id)
|
||||
.in_definition_order()
|
||||
.filter(|item| item.kind == ty::AssocKind::Fn)
|
||||
.filter_map(|item| {
|
||||
object_safety_violation_for_method(tcx, trait_def_id, &item)
|
||||
.filter_map(|&item| {
|
||||
object_safety_violation_for_method(tcx, trait_def_id, item)
|
||||
.map(|(code, span)| ObjectSafetyViolation::Method(item.name, code, span))
|
||||
})
|
||||
.collect();
|
||||
|
@ -387,7 +387,7 @@ fn generics_require_sized_self(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
|
|||
fn object_safety_violation_for_method(
|
||||
tcx: TyCtxt<'_>,
|
||||
trait_def_id: DefId,
|
||||
method: &ty::AssocItem,
|
||||
method: ty::AssocItem,
|
||||
) -> Option<(MethodViolationCode, Span)> {
|
||||
debug!("object_safety_violation_for_method({:?}, {:?})", trait_def_id, method);
|
||||
// Any method that has a `Self : Sized` requisite is otherwise
|
||||
|
@ -420,7 +420,7 @@ fn object_safety_violation_for_method(
|
|||
fn virtual_call_violation_for_method<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
method: &ty::AssocItem,
|
||||
method: ty::AssocItem,
|
||||
) -> Option<MethodViolationCode> {
|
||||
let sig = tcx.fn_sig(method.def_id).subst_identity();
|
||||
|
||||
|
@ -722,7 +722,7 @@ fn object_ty_for_trait<'tcx>(
|
|||
#[allow(dead_code)]
|
||||
fn receiver_is_dispatchable<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
method: &ty::AssocItem,
|
||||
method: ty::AssocItem,
|
||||
receiver_ty: Ty<'tcx>,
|
||||
) -> bool {
|
||||
debug!("receiver_is_dispatchable: method = {:?}, receiver_ty = {:?}", method, receiver_ty);
|
||||
|
|
|
@ -2149,7 +2149,7 @@ fn confirm_impl_candidate<'cx, 'tcx>(
|
|||
} else {
|
||||
ty.map_bound(|ty| ty.into())
|
||||
};
|
||||
if !check_substs_compatible(tcx, &assoc_ty.item, substs) {
|
||||
if !check_substs_compatible(tcx, assoc_ty.item, substs) {
|
||||
let err = tcx.ty_error_with_message(
|
||||
obligation.cause.span,
|
||||
"impl item and trait item have different parameters",
|
||||
|
@ -2164,7 +2164,7 @@ fn confirm_impl_candidate<'cx, 'tcx>(
|
|||
// Verify that the trait item and its implementation have compatible substs lists
|
||||
fn check_substs_compatible<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
assoc_item: &ty::AssocItem,
|
||||
assoc_item: ty::AssocItem,
|
||||
substs: ty::SubstsRef<'tcx>,
|
||||
) -> bool {
|
||||
fn check_substs_compatible_inner<'tcx>(
|
||||
|
@ -2238,7 +2238,7 @@ fn confirm_impl_trait_in_trait_candidate<'tcx>(
|
|||
leaf_def.defining_node,
|
||||
);
|
||||
|
||||
if !check_substs_compatible(tcx, &leaf_def.item, impl_fn_substs) {
|
||||
if !check_substs_compatible(tcx, leaf_def.item, impl_fn_substs) {
|
||||
let err = tcx.ty_error_with_message(
|
||||
obligation.cause.span,
|
||||
"impl method and trait method have different parameters",
|
||||
|
|
|
@ -399,7 +399,7 @@ pub(crate) fn assoc_def(
|
|||
// If there is no such item in that impl, this function will fail with a
|
||||
// cycle error if the specialization graph is currently being built.
|
||||
if let Some(&impl_item_id) = tcx.impl_item_implementor_ids(impl_def_id).get(&assoc_def_id) {
|
||||
let &item = tcx.associated_item(impl_item_id);
|
||||
let item = tcx.associated_item(impl_item_id);
|
||||
let impl_node = Node::Impl(impl_def_id);
|
||||
return Ok(LeafDef {
|
||||
item,
|
||||
|
|
|
@ -197,12 +197,12 @@ fn own_existential_vtable_entries(tcx: TyCtxt<'_>, trait_def_id: DefId) -> &[Def
|
|||
.in_definition_order()
|
||||
.filter(|item| item.kind == ty::AssocKind::Fn);
|
||||
// Now list each method's DefId (for within its trait).
|
||||
let own_entries = trait_methods.filter_map(move |trait_method| {
|
||||
let own_entries = trait_methods.filter_map(move |&trait_method| {
|
||||
debug!("own_existential_vtable_entry: trait_method={:?}", trait_method);
|
||||
let def_id = trait_method.def_id;
|
||||
|
||||
// Some methods cannot be called on an object; skip those.
|
||||
if !is_vtable_safe_method(tcx, trait_def_id, &trait_method) {
|
||||
if !is_vtable_safe_method(tcx, trait_def_id, trait_method) {
|
||||
debug!("own_existential_vtable_entry: not vtable safe");
|
||||
return None;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue