1
Fork 0

Simplify code as suggested by the review

This commit is contained in:
Maybe Waffle 2023-06-13 11:46:40 +00:00
parent f2545fb225
commit 5008a08acf

View file

@ -918,24 +918,15 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
} }
traits::vtable::VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => { traits::vtable::VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => {
let existential_trait_ref = trait_ref.map_bound(|trait_ref| {
ty::ExistentialTraitRef::erase_self_ty(tcx, trait_ref)
});
// Lookup the shape of vtable for the trait. // Lookup the shape of vtable for the trait.
let own_existential_entries = let own_existential_entries =
tcx.own_existential_vtable_entries(existential_trait_ref.def_id()); tcx.own_existential_vtable_entries(trait_ref.def_id());
let own_entries = own_existential_entries.iter().copied().map(|_def_id| { // The original code here ignores the method if its predicates are impossible.
// The original code here ignores the method if its predicates are impossible. // We can't really do that as, for example, all not trivial bounds on generic
// We can't really do that as, for example, all not trivial bounds on generic // parameters are impossible (since we don't know the parameters...),
// parameters are impossible (since we don't know the parameters...), // see the comment above.
// see the comment above. unupcasted_cost += own_existential_entries.len();
1
});
unupcasted_cost += own_entries.sum::<usize>();
if emit_vptr { if emit_vptr {
upcast_cost += 1; upcast_cost += 1;