Skip to content

Commit

Permalink
Rollup merge of rust-lang#83599 - jyn514:unorderable, r=Aaron1011
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Dylan-DPC committed Apr 2, 2021
2 parents da5dd57 + a0957c9 commit 4410fdf
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 @@ -118,8 +119,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 4410fdf

Please sign in to comment.