Skip to content

Commit

Permalink
Avoid sorting by DefId for necessary_variants()
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Mar 28, 2021
1 parent 8cd7d86 commit a0957c9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/rustc_hir/src/pat_util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::def::{CtorOf, DefKind, Res};
use crate::def_id::DefId;
use crate::hir::{self, HirId, PatKind};
use rustc_data_structures::stable_set::FxHashSet;
use rustc_span::symbol::Ident;
use rustc_span::Span;

Expand Down Expand Up @@ -138,8 +139,10 @@ impl hir::Pat<'_> {
}
_ => true,
});
variants.sort();
variants.dedup();
// We remove duplicates by inserting into a `FxHashSet` to avoid re-ordering
// the bounds
let mut duplicates = FxHashSet::default();
variants.retain(|def_id| duplicates.insert(*def_id));
variants
}

Expand Down

0 comments on commit a0957c9

Please sign in to comment.