Delegation: second attempt to improve perf

This commit is contained in:
Bryanskiy
2024-07-31 18:58:04 +03:00
parent 595316b400
commit 9b097b2d44
5 changed files with 33 additions and 27 deletions

View File

@@ -115,13 +115,6 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
None => {}
}
// For a delegation item inherit predicates from callee.
if let Some(sig_id) = tcx.hir().opt_delegation_sig_id(def_id)
&& let Some(predicates) = inherit_predicates_for_delegation_item(tcx, def_id, sig_id)
{
return predicates;
}
let hir_id = tcx.local_def_id_to_hir_id(def_id);
let node = tcx.hir_node(hir_id);
@@ -151,6 +144,16 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Gen
ItemKind::Trait(_, _, _, self_bounds, ..) | ItemKind::TraitAlias(_, self_bounds) => {
is_trait = Some(self_bounds);
}
ItemKind::Fn(sig, _, _) => {
// For a delegation item inherit predicates from callee.
if let Some(sig_id) = sig.decl.opt_delegation_sig_id()
&& let Some(predicates) =
inherit_predicates_for_delegation_item(tcx, def_id, sig_id)
{
return predicates;
}
}
_ => {}
}
};