@@ -398,23 +398,19 @@ fn clean_type_outlives_predicate<'tcx>(
398
398
} )
399
399
}
400
400
401
- impl < ' tcx > Clean < ' tcx , Term > for ty:: Term < ' tcx > {
402
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Term {
403
- match self {
404
- ty:: Term :: Ty ( ty) => Term :: Type ( clean_middle_ty ( * ty, cx, None ) ) ,
405
- ty:: Term :: Const ( c) => Term :: Constant ( clean_middle_const ( * c, cx) ) ,
406
- }
401
+ fn clean_middle_term < ' tcx > ( term : ty:: Term < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Term {
402
+ match term {
403
+ ty:: Term :: Ty ( ty) => Term :: Type ( clean_middle_ty ( ty, cx, None ) ) ,
404
+ ty:: Term :: Const ( c) => Term :: Constant ( clean_middle_const ( c, cx) ) ,
407
405
}
408
406
}
409
407
410
- impl < ' tcx > Clean < ' tcx , Term > for hir:: Term < ' tcx > {
411
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Term {
412
- match self {
413
- hir:: Term :: Ty ( ty) => Term :: Type ( clean_ty ( ty, cx) ) ,
414
- hir:: Term :: Const ( c) => {
415
- let def_id = cx. tcx . hir ( ) . local_def_id ( c. hir_id ) ;
416
- Term :: Constant ( clean_middle_const ( ty:: Const :: from_anon_const ( cx. tcx , def_id) , cx) )
417
- }
408
+ fn clean_hir_term < ' tcx > ( term : & hir:: Term < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Term {
409
+ match term {
410
+ hir:: Term :: Ty ( ty) => Term :: Type ( clean_ty ( ty, cx) ) ,
411
+ hir:: Term :: Const ( c) => {
412
+ let def_id = cx. tcx . hir ( ) . local_def_id ( c. hir_id ) ;
413
+ Term :: Constant ( clean_middle_const ( ty:: Const :: from_anon_const ( cx. tcx , def_id) , cx) )
418
414
}
419
415
}
420
416
}
@@ -426,7 +422,7 @@ fn clean_projection_predicate<'tcx>(
426
422
let ty:: ProjectionPredicate { projection_ty, term } = pred;
427
423
WherePredicate :: EqPredicate {
428
424
lhs : clean_projection ( projection_ty, cx, None ) ,
429
- rhs : term . clean ( cx) ,
425
+ rhs : clean_middle_term ( term , cx) ,
430
426
}
431
427
}
432
428
@@ -474,47 +470,44 @@ fn projection_to_path_segment<'tcx>(
474
470
}
475
471
}
476
472
477
- impl < ' tcx > Clean < ' tcx , GenericParamDef > for ty:: GenericParamDef {
478
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> GenericParamDef {
479
- let ( name, kind) = match self . kind {
480
- ty:: GenericParamDefKind :: Lifetime => {
481
- ( self . name , GenericParamDefKind :: Lifetime { outlives : vec ! [ ] } )
482
- }
483
- ty:: GenericParamDefKind :: Type { has_default, synthetic, .. } => {
484
- let default = if has_default {
485
- Some ( clean_middle_ty ( cx. tcx . type_of ( self . def_id ) , cx, Some ( self . def_id ) ) )
486
- } else {
487
- None
488
- } ;
489
- (
490
- self . name ,
491
- GenericParamDefKind :: Type {
492
- did : self . def_id ,
493
- bounds : vec ! [ ] , // These are filled in from the where-clauses.
494
- default : default. map ( Box :: new) ,
495
- synthetic,
496
- } ,
497
- )
498
- }
499
- ty:: GenericParamDefKind :: Const { has_default } => (
500
- self . name ,
501
- GenericParamDefKind :: Const {
502
- did : self . def_id ,
503
- ty : Box :: new ( clean_middle_ty (
504
- cx. tcx . type_of ( self . def_id ) ,
505
- cx,
506
- Some ( self . def_id ) ,
507
- ) ) ,
508
- default : match has_default {
509
- true => Some ( Box :: new ( cx. tcx . const_param_default ( self . def_id ) . to_string ( ) ) ) ,
510
- false => None ,
511
- } ,
473
+ fn clean_generic_param_def < ' tcx > (
474
+ def : & ty:: GenericParamDef ,
475
+ cx : & mut DocContext < ' tcx > ,
476
+ ) -> GenericParamDef {
477
+ let ( name, kind) = match def. kind {
478
+ ty:: GenericParamDefKind :: Lifetime => {
479
+ ( def. name , GenericParamDefKind :: Lifetime { outlives : vec ! [ ] } )
480
+ }
481
+ ty:: GenericParamDefKind :: Type { has_default, synthetic, .. } => {
482
+ let default = if has_default {
483
+ Some ( clean_middle_ty ( cx. tcx . type_of ( def. def_id ) , cx, Some ( def. def_id ) ) )
484
+ } else {
485
+ None
486
+ } ;
487
+ (
488
+ def. name ,
489
+ GenericParamDefKind :: Type {
490
+ did : def. def_id ,
491
+ bounds : vec ! [ ] , // These are filled in from the where-clauses.
492
+ default : default. map ( Box :: new) ,
493
+ synthetic,
512
494
} ,
513
- ) ,
514
- } ;
495
+ )
496
+ }
497
+ ty:: GenericParamDefKind :: Const { has_default } => (
498
+ def. name ,
499
+ GenericParamDefKind :: Const {
500
+ did : def. def_id ,
501
+ ty : Box :: new ( clean_middle_ty ( cx. tcx . type_of ( def. def_id ) , cx, Some ( def. def_id ) ) ) ,
502
+ default : match has_default {
503
+ true => Some ( Box :: new ( cx. tcx . const_param_default ( def. def_id ) . to_string ( ) ) ) ,
504
+ false => None ,
505
+ } ,
506
+ } ,
507
+ ) ,
508
+ } ;
515
509
516
- GenericParamDef { name, kind }
517
- }
510
+ GenericParamDef { name, kind }
518
511
}
519
512
520
513
fn clean_generic_param < ' tcx > (
@@ -672,7 +665,7 @@ fn clean_ty_generics<'tcx>(
672
665
. iter ( )
673
666
. filter_map ( |param| match param. kind {
674
667
ty:: GenericParamDefKind :: Lifetime if param. name == kw:: UnderscoreLifetime => None ,
675
- ty:: GenericParamDefKind :: Lifetime => Some ( param . clean ( cx) ) ,
668
+ ty:: GenericParamDefKind :: Lifetime => Some ( clean_generic_param_def ( param , cx) ) ,
676
669
ty:: GenericParamDefKind :: Type { synthetic, .. } => {
677
670
if param. name == kw:: SelfUpper {
678
671
assert_eq ! ( param. index, 0 ) ;
@@ -682,9 +675,9 @@ fn clean_ty_generics<'tcx>(
682
675
impl_trait. insert ( param. index . into ( ) , vec ! [ ] ) ;
683
676
return None ;
684
677
}
685
- Some ( param . clean ( cx) )
678
+ Some ( clean_generic_param_def ( param , cx) )
686
679
}
687
- ty:: GenericParamDefKind :: Const { .. } => Some ( param . clean ( cx) ) ,
680
+ ty:: GenericParamDefKind :: Const { .. } => Some ( clean_generic_param_def ( param , cx) ) ,
688
681
} )
689
682
. collect :: < Vec < GenericParamDef > > ( ) ;
690
683
@@ -1682,7 +1675,9 @@ pub(crate) fn clean_middle_ty<'tcx>(
1682
1675
. projection_ty ,
1683
1676
cx,
1684
1677
) ,
1685
- kind : TypeBindingKind :: Equality { term : pb. skip_binder ( ) . term . clean ( cx) } ,
1678
+ kind : TypeBindingKind :: Equality {
1679
+ term : clean_middle_term ( pb. skip_binder ( ) . term , cx) ,
1680
+ } ,
1686
1681
} ) ;
1687
1682
}
1688
1683
@@ -1746,7 +1741,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
1746
1741
Some ( TypeBinding {
1747
1742
assoc : projection_to_path_segment ( proj. projection_ty , cx) ,
1748
1743
kind : TypeBindingKind :: Equality {
1749
- term : proj. term . clean ( cx) ,
1744
+ term : clean_middle_term ( proj. term , cx) ,
1750
1745
} ,
1751
1746
} )
1752
1747
} else {
@@ -2283,7 +2278,7 @@ impl<'tcx> Clean<'tcx, TypeBindingKind> for hir::TypeBindingKind<'tcx> {
2283
2278
fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> TypeBindingKind {
2284
2279
match * self {
2285
2280
hir:: TypeBindingKind :: Equality { ref term } => {
2286
- TypeBindingKind :: Equality { term : term . clean ( cx) }
2281
+ TypeBindingKind :: Equality { term : clean_hir_term ( term , cx) }
2287
2282
}
2288
2283
hir:: TypeBindingKind :: Constraint { bounds } => TypeBindingKind :: Constraint {
2289
2284
bounds : bounds. iter ( ) . filter_map ( |b| b. clean ( cx) ) . collect ( ) ,
0 commit comments