Skip to content

Commit a0957c9

Browse files
committed
Avoid sorting by DefId for necessary_variants()
1 parent 8cd7d86 commit a0957c9

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

@@ -138,8 +139,10 @@ impl hir::Pat<'_> {
138139
}
139140
_ => true,
140141
});
141-
variants.sort();
142-
variants.dedup();
142+
// We remove duplicates by inserting into a `FxHashSet` to avoid re-ordering
143+
// the bounds
144+
let mut duplicates = FxHashSet::default();
145+
variants.retain(|def_id| duplicates.insert(*def_id));
143146
variants
144147
}
145148

0 commit comments

Comments
 (0)