Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid sorting by DefId for necessary_variants() #83599

Merged
merged 1 commit into from
Apr 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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