]> git.lizzy.rs Git - rust.git/commitdiff
Use BTreeMap for deterministic iter order
authorShotaro Yamada <sinkuu@sinkuu.xyz>
Tue, 9 Jul 2019 07:37:55 +0000 (16:37 +0900)
committerShotaro Yamada <sinkuu@sinkuu.xyz>
Mon, 19 Aug 2019 08:49:54 +0000 (17:49 +0900)
src/librustdoc/clean/mod.rs
src/librustdoc/core.rs

index 93e650d6d61ae251c6582ca4d3ddacad9786a3d2..37ee79aa9e4f15b1a3fc6c900ed52b6723137952 100644 (file)
@@ -1693,12 +1693,13 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
                                     &'a &'tcx ty::GenericPredicates<'tcx>) {
     fn clean(&self, cx: &DocContext<'_>) -> Generics {
         use self::WherePredicate as WP;
+        use std::collections::BTreeMap;
 
         let (gens, preds) = *self;
 
         // Don't populate `cx.impl_trait_bounds` before `clean`ning `where` clauses,
         // since `Clean for ty::Predicate` would consume them.
-        let mut impl_trait = FxHashMap::<ImplTraitParam, Vec<GenericBound>>::default();
+        let mut impl_trait = BTreeMap::<ImplTraitParam, Vec<GenericBound>>::default();
 
         // Bounds in the type_params and lifetimes fields are repeated in the
         // predicates field (see rustc_typeck::collect::ty_generics), so remove
@@ -1777,16 +1778,14 @@ fn clean(&self, cx: &DocContext<'_>) -> Generics {
             })
             .collect::<Vec<_>>();
 
-        // Move `TraitPredicate`s to the front.
-        for (_, bounds) in impl_trait.iter_mut() {
+        for (param, mut bounds) in impl_trait {
+            // Move trait bounds to the front.
             bounds.sort_by_key(|b| if let GenericBound::TraitBound(..) = b {
                 false
             } else {
                 true
             });
-        }
 
-        for (param, mut bounds) in impl_trait {
             if let crate::core::ImplTraitParam::ParamIndex(idx) = param {
                 if let Some(proj) = impl_trait_proj.remove(&idx) {
                     for (trait_did, name, rhs) in proj {
index 592a24fa4ae1a715d8eb7aaade67229d23f1d40c..04e69613d4b0f145daf8f465ded97b33f6ced855 100644 (file)
@@ -462,7 +462,7 @@ fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
 
 /// `DefId` or parameter index (`ty::ParamTy.index`) of a synthetic type parameter
 /// for `impl Trait` in argument position.
-#[derive(Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
 pub enum ImplTraitParam {
     DefId(DefId),
     ParamIndex(u32),