Rollup merge of #131328 - ismailarilik:remove-unnecessary-sorts-in-rustc-hir-analysis, r=compiler-errors

Remove unnecessary sorts in `rustc_hir_analysis`

A follow-up after #131140. Here the related objects are `IndexSet` so do not require a sort to stay stable. And they don't need to be `mut` anymore.

r? ```@compiler-errors```
This commit is contained in:
Matthias Krüger 2024-10-15 05:12:36 +02:00 committed by GitHub
commit b9cb20154d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 7 deletions

View File

@ -531,7 +531,7 @@ fn check_gat_where_clauses(tcx: TyCtxt<'_>, trait_def_id: LocalDefId) {
debug!(?required_bounds); debug!(?required_bounds);
let param_env = tcx.param_env(gat_def_id); let param_env = tcx.param_env(gat_def_id);
let mut unsatisfied_bounds: Vec<_> = required_bounds let unsatisfied_bounds: Vec<_> = required_bounds
.into_iter() .into_iter()
.filter(|clause| match clause.kind().skip_binder() { .filter(|clause| match clause.kind().skip_binder() {
ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(a, b)) => { 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()) .map(|clause| clause.to_string())
.collect(); .collect();
// We sort so that order is predictable
unsatisfied_bounds.sort();
if !unsatisfied_bounds.is_empty() { if !unsatisfied_bounds.is_empty() {
let plural = pluralize!(unsatisfied_bounds.len()); let plural = pluralize!(unsatisfied_bounds.len());
let suggestion = format!( let suggestion = format!(

View File

@ -319,9 +319,7 @@ struct ConnectedRegion {
// List of connected regions is built. Now, run the overlap check // List of connected regions is built. Now, run the overlap check
// for each pair of impl blocks in the same connected region. // for each pair of impl blocks in the same connected region.
for region in connected_regions.into_iter().flatten() { for region in connected_regions.into_iter().flatten() {
let mut impl_blocks = let impl_blocks = region.impl_blocks.into_iter().collect::<SmallVec<[usize; 8]>>();
region.impl_blocks.into_iter().collect::<SmallVec<[usize; 8]>>();
impl_blocks.sort_unstable();
for (i, &impl1_items_idx) in impl_blocks.iter().enumerate() { for (i, &impl1_items_idx) in impl_blocks.iter().enumerate() {
let &(&impl1_def_id, impl_items1) = &impls_items[impl1_items_idx]; let &(&impl1_def_id, impl_items1) = &impls_items[impl1_items_idx];
res = res.and(self.check_for_duplicate_items_in_impl(impl1_def_id)); res = res.and(self.check_for_duplicate_items_in_impl(impl1_def_id));