diff options
| author | Guillaume Gomez <guillaume.gomez@huawei.com> | 2021-09-19 16:52:03 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume.gomez@huawei.com> | 2021-09-19 20:23:12 +0200 |
| commit | b226d1751d16d22aa51969702757fa620d3b1eab (patch) | |
| tree | 80ac0b3513c550607f958b29a7fa2d8db391d1ea | |
| parent | e0c38af27cb5f6f961809601b717d6afc3b190ee (diff) | |
| download | rust-b226d1751d16d22aa51969702757fa620d3b1eab.tar.gz rust-b226d1751d16d22aa51969702757fa620d3b1eab.zip | |
Fix generics where bounds order
| -rw-r--r-- | src/librustdoc/clean/simplify.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index d139b19f5dc..257af6ab910 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -11,8 +11,7 @@ //! This module attempts to reconstruct the original where and/or parameter //! bounds by special casing scenarios such as these. Fun! -use std::collections::BTreeMap; - +use rustc_data_structures::fx::FxIndexMap; use rustc_hir::def_id::DefId; use rustc_middle::ty; use rustc_span::Symbol; @@ -23,8 +22,11 @@ use crate::clean::WherePredicate as WP; use crate::core::DocContext; crate fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> { - // First, partition the where clause into its separate components - let mut params: BTreeMap<_, (Vec<_>, Vec<_>)> = BTreeMap::new(); + // First, partition the where clause into its separate components. + // + // We use `FxIndexMap` so that the insertion order is preserved to prevent messing up to + // the order of the generated bounds. + let mut params: FxIndexMap<Symbol, (Vec<_>, Vec<_>)> = FxIndexMap::default(); let mut lifetimes = Vec::new(); let mut equalities = Vec::new(); let mut tybounds = Vec::new(); |
