From 5008a08acf6d3e8e01e6b1768850579da6058aea Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 13 Jun 2023 11:46:40 +0000 Subject: [PATCH] Simplify code as suggested by the review --- compiler/rustc_interface/src/passes.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index be6bd913790..d61f2d0668a 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -918,24 +918,15 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { } 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. 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. - // 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...), - // see the comment above. - - 1 - }); - - unupcasted_cost += own_entries.sum::(); + // 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 + // parameters are impossible (since we don't know the parameters...), + // see the comment above. + unupcasted_cost += own_existential_entries.len(); if emit_vptr { upcast_cost += 1;