Skip to content

Commit cb17136

Browse files
committed
Auto merge of rust-lang#83599 - jyn514:unorderable, r=Aaron1011
Avoid sorting by DefId for `necessary_variants()` Follow-up to rust-lang#83074. Originally I tried removing `impl Ord for DefId` but that hit *lots* of errors 😅 so I thought I would start with easy things. I am not sure whether this could actually cause invalid query results, but this is used from `MarkSymbolVisitor::visit_arm` so it's at least feasible. r? `@Aaron1011`
2 parents 621d4b7 + a0957c9 commit cb17136

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/rustc_hir/src/pat_util.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::def::{CtorOf, DefKind, Res};
22
use crate::def_id::DefId;
33
use crate::hir::{self, HirId, PatKind};
4+
use rustc_data_structures::stable_set::FxHashSet;
45
use rustc_span::symbol::Ident;
56
use rustc_span::Span;
67

@@ -118,8 +119,10 @@ impl hir::Pat<'_> {
118119
}
119120
_ => true,
120121
});
121-
variants.sort();
122-
variants.dedup();
122+
// We remove duplicates by inserting into a `FxHashSet` to avoid re-ordering
123+
// the bounds
124+
let mut duplicates = FxHashSet::default();
125+
variants.retain(|def_id| duplicates.insert(*def_id));
123126
variants
124127
}
125128

0 commit comments

Comments
 (0)