Skip to content

Commit 3620456

Browse files
committed
Use BTreeMap for deterministic iter order
1 parent cc6dbb4 commit 3620456

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/librustdoc/clean/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1693,12 +1693,13 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
16931693
&'a &'tcx ty::GenericPredicates<'tcx>) {
16941694
fn clean(&self, cx: &DocContext<'_>) -> Generics {
16951695
use self::WherePredicate as WP;
1696+
use std::collections::BTreeMap;
16961697

16971698
let (gens, preds) = *self;
16981699

16991700
// Don't populate `cx.impl_trait_bounds` before `clean`ning `where` clauses,
17001701
// since `Clean for ty::Predicate` would consume them.
1701-
let mut impl_trait = FxHashMap::<ImplTraitParam, Vec<GenericBound>>::default();
1702+
let mut impl_trait = BTreeMap::<ImplTraitParam, Vec<GenericBound>>::default();
17021703

17031704
// Bounds in the type_params and lifetimes fields are repeated in the
17041705
// predicates field (see rustc_typeck::collect::ty_generics), so remove
@@ -1777,16 +1778,14 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17771778
})
17781779
.collect::<Vec<_>>();
17791780

1780-
// Move `TraitPredicate`s to the front.
1781-
for (_, bounds) in impl_trait.iter_mut() {
1781+
for (param, mut bounds) in impl_trait {
1782+
// Move trait bounds to the front.
17821783
bounds.sort_by_key(|b| if let GenericBound::TraitBound(..) = b {
17831784
false
17841785
} else {
17851786
true
17861787
});
1787-
}
17881788

1789-
for (param, mut bounds) in impl_trait {
17901789
if let crate::core::ImplTraitParam::ParamIndex(idx) = param {
17911790
if let Some(proj) = impl_trait_proj.remove(&idx) {
17921791
for (trait_did, name, rhs) in proj {

src/librustdoc/core.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
462462

463463
/// `DefId` or parameter index (`ty::ParamTy.index`) of a synthetic type parameter
464464
/// for `impl Trait` in argument position.
465-
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
465+
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
466466
pub enum ImplTraitParam {
467467
DefId(DefId),
468468
ParamIndex(u32),

0 commit comments

Comments
 (0)