From a0e687f0348af5d269c8ba0ac9bbb52308850c6a Mon Sep 17 00:00:00 2001 From: ismailarilik Date: Sun, 6 Oct 2024 15:57:23 +0300 Subject: [PATCH] Remove unnecessary sorts in `rustc_hir_analysis`. This is an attempt to gain the performance loss after the PR #131140. Here the related objects are `IndexSet` so do not require a sort to stay stable. --- compiler/rustc_hir_analysis/src/check/wfcheck.rs | 5 +---- .../src/coherence/inherent_impls_overlap.rs | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index 3a9d2640eee93..3079fd71b0c2d 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -531,7 +531,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) { debug!(?required_bounds); let param_env = tcx.param_env(gat_def_id); - let mut unsatisfied_bounds: Vec<_> = required_bounds + let unsatisfied_bounds: Vec<_> = required_bounds .into_iter() .filter(|clause| match clause.kind().skip_binder() { ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => { @@ -552,9 +552,6 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) { .map(|clause| clause.to_string()) .collect(); - // We sort so that order is predictable - unsatisfied_bounds.sort(); - if !unsatisfied_bounds.is_empty() { let plural = pluralize!(unsatisfied_bounds.len()); let suggestion = format!( diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs index d1c888a185ed9..5127e73d9784d 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls_overlap.rs @@ -319,9 +319,7 @@ impl<'tcx> InherentOverlapChecker<'tcx> { // List of connected regions is built. Now, run the overlap check // for each pair of impl blocks in the same connected region. for region in connected_regions.into_iter().flatten() { - let mut impl_blocks = - region.impl_blocks.into_iter().collect::>(); - impl_blocks.sort_unstable(); + let impl_blocks = region.impl_blocks.into_iter().collect::>(); for (i, &impl1_items_idx) in impl_blocks.iter().enumerate() { let &(&impl1_def_id, impl_items1) = &impls_items[impl1_items_idx]; res = res.and(self.check_for_duplicate_items_in_impl(impl1_def_id));