14
14
use rustc_data_structures:: fx:: FxIndexMap ;
15
15
use rustc_hir:: def_id:: DefId ;
16
16
use rustc_middle:: ty;
17
- use rustc_span:: Symbol ;
18
17
19
18
use crate :: clean;
20
19
use crate :: clean:: GenericArgs as PP ;
@@ -26,21 +25,17 @@ pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
26
25
//
27
26
// We use `FxIndexMap` so that the insertion order is preserved to prevent messing up to
28
27
// the order of the generated bounds.
29
- let mut params : FxIndexMap < Symbol , ( Vec < _ > , Vec < _ > ) > = FxIndexMap :: default ( ) ;
28
+ let mut tybounds = FxIndexMap :: default ( ) ;
30
29
let mut lifetimes = Vec :: new ( ) ;
31
30
let mut equalities = Vec :: new ( ) ;
32
- let mut tybounds = Vec :: new ( ) ;
33
31
34
32
for clause in clauses {
35
33
match clause {
36
- WP :: BoundPredicate { ty, bounds, bound_params } => match ty {
37
- clean:: Generic ( s) => {
38
- let ( b, p) = params. entry ( s) . or_default ( ) ;
39
- b. extend ( bounds) ;
40
- p. extend ( bound_params) ;
41
- }
42
- t => tybounds. push ( ( t, ( bounds, bound_params) ) ) ,
43
- } ,
34
+ WP :: BoundPredicate { ty, bounds, bound_params } => {
35
+ let ( b, p) : & mut ( Vec < _ > , Vec < _ > ) = tybounds. entry ( ty) . or_default ( ) ;
36
+ b. extend ( bounds) ;
37
+ p. extend ( bound_params) ;
38
+ }
44
39
WP :: RegionPredicate { lifetime, bounds } => {
45
40
lifetimes. push ( ( lifetime, bounds) ) ;
46
41
}
@@ -49,14 +44,17 @@ pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
49
44
}
50
45
51
46
// Look for equality predicates on associated types that can be merged into
52
- // general bound predicates
47
+ // general bound predicates.
53
48
equalities. retain ( |& ( ref lhs, ref rhs) | {
54
- let Some ( ( self_, trait_did, name) ) = lhs. projection ( ) else {
55
- return true ;
56
- } ;
57
- let clean:: Generic ( generic) = self_ else { return true } ;
58
- let Some ( ( bounds, _) ) = params. get_mut ( generic) else { return true } ;
59
-
49
+ let Some ( ( ty, trait_did, name) ) = lhs. projection ( ) else { return true ; } ;
50
+ // FIXME(fmease): We don't handle HRTBs correctly here.
51
+ // Pass `_bound_params` (higher-rank lifetimes) to a modified version of
52
+ // `merge_bounds`. That vector is currently always empty though since we
53
+ // don't keep track of late-bound lifetimes when cleaning projection
54
+ // predicates to cleaned equality predicates while we should first query
55
+ // them with `collect_referenced_late_bound_regions` and then store them
56
+ // (or something similar). For prior art, see `clean::auto_trait`.
57
+ let Some ( ( bounds, _bound_params) ) = tybounds. get_mut ( ty) else { return true } ;
60
58
merge_bounds ( cx, bounds, trait_did, name, rhs)
61
59
} ) ;
62
60
@@ -65,11 +63,6 @@ pub(crate) fn where_clauses(cx: &DocContext<'_>, clauses: Vec<WP>) -> Vec<WP> {
65
63
clauses. extend (
66
64
lifetimes. into_iter ( ) . map ( |( lt, bounds) | WP :: RegionPredicate { lifetime : lt, bounds } ) ,
67
65
) ;
68
- clauses. extend ( params. into_iter ( ) . map ( |( k, ( bounds, params) ) | WP :: BoundPredicate {
69
- ty : clean:: Generic ( k) ,
70
- bounds,
71
- bound_params : params,
72
- } ) ) ;
73
66
clauses. extend ( tybounds. into_iter ( ) . map ( |( ty, ( bounds, bound_params) ) | WP :: BoundPredicate {
74
67
ty,
75
68
bounds,
0 commit comments