@@ -152,8 +152,8 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
152152 }
153153}
154154
155- impl Clean < Type > for ( ty:: TraitRef < ' _ > , & [ TypeBinding ] ) {
156- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Type {
155+ impl Clean < Path > for ( ty:: TraitRef < ' _ > , & [ TypeBinding ] ) {
156+ fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Path {
157157 let ( trait_ref, bounds) = * self ;
158158 let kind = cx. tcx . def_kind ( trait_ref. def_id ) . into ( ) ;
159159 if !matches ! ( kind, ItemType :: Trait | ItemType :: TraitAlias ) {
@@ -168,16 +168,13 @@ impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
168168
169169 debug ! ( "ty::TraitRef\n subst: {:?}\n " , trait_ref. substs) ;
170170
171- ResolvedPath { path, did : trait_ref . def_id }
171+ path
172172 }
173173}
174174
175- impl < ' tcx > Clean < GenericBound > for ty:: TraitRef < ' tcx > {
176- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> GenericBound {
177- GenericBound :: TraitBound (
178- PolyTrait { trait_ : ( * self , & [ ] [ ..] ) . clean ( cx) , generic_params : vec ! [ ] } ,
179- hir:: TraitBoundModifier :: None ,
180- )
175+ impl Clean < Path > for ty:: TraitRef < ' tcx > {
176+ fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Path {
177+ ( * self , & [ ] [ ..] ) . clean ( cx)
181178 }
182179}
183180
@@ -384,16 +381,13 @@ impl<'tcx> Clean<WherePredicate> for ty::ProjectionPredicate<'tcx> {
384381impl < ' tcx > Clean < Type > for ty:: ProjectionTy < ' tcx > {
385382 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Type {
386383 let lifted = self . lift_to_tcx ( cx. tcx ) . unwrap ( ) ;
387- let trait_ = match lifted. trait_ref ( cx. tcx ) . clean ( cx) {
388- GenericBound :: TraitBound ( t, _) => t. trait_ ,
389- GenericBound :: Outlives ( _) => panic ! ( "cleaning a trait got a lifetime" ) ,
390- } ;
384+ let trait_ = lifted. trait_ref ( cx. tcx ) . clean ( cx) ;
391385 let self_type = self . self_ty ( ) . clean ( cx) ;
392386 Type :: QPath {
393387 name : cx. tcx . associated_item ( self . item_def_id ) . ident . name ,
394388 self_def_id : self_type. def_id ( ) ,
395389 self_type : box self_type,
396- trait_ : box trait_ ,
390+ trait_,
397391 }
398392 }
399393}
@@ -896,10 +890,11 @@ impl Clean<bool> for hir::IsAuto {
896890 }
897891}
898892
899- impl Clean < Type > for hir:: TraitRef < ' _ > {
900- fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Type {
893+ impl Clean < Path > for hir:: TraitRef < ' _ > {
894+ fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Path {
901895 let path = self . path . clean ( cx) ;
902- resolve_type ( cx, path)
896+ register_res ( cx, path. res ) ;
897+ path
903898 }
904899}
905900
@@ -1105,9 +1100,8 @@ impl Clean<Item> for ty::AssocItem {
11051100 if * name != my_name {
11061101 return None ;
11071102 }
1108- match * * trait_ {
1109- ResolvedPath { did, .. } if did == self . container . id ( ) => { }
1110- _ => return None ,
1103+ if trait_. def_id ( ) != self . container . id ( ) {
1104+ return None ;
11111105 }
11121106 match * * self_type {
11131107 Generic ( ref s) if * s == kw:: SelfUpper => { }
@@ -1273,19 +1267,18 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
12731267 return normalized_value. clean ( cx) ;
12741268 }
12751269
1276- let segments = if p. is_global ( ) { & p. segments [ 1 ..] } else { & p. segments } ;
1277- let trait_segments = & segments[ ..segments. len ( ) - 1 ] ;
1270+ let trait_segments = & p. segments [ ..p. segments . len ( ) - 1 ] ;
12781271 let trait_def = cx. tcx . associated_item ( p. res . def_id ( ) ) . container . id ( ) ;
1279- let trait_path = self :: Path {
1280- global : p. is_global ( ) ,
1272+ let trait_ = self :: Path {
12811273 res : Res :: Def ( DefKind :: Trait , trait_def) ,
12821274 segments : trait_segments. clean ( cx) ,
12831275 } ;
1276+ register_res ( cx, trait_. res ) ;
12841277 Type :: QPath {
12851278 name : p. segments . last ( ) . expect ( "segments were empty" ) . ident . name ,
12861279 self_def_id : Some ( DefId :: local ( qself. hir_id . owner . local_def_index ) ) ,
12871280 self_type : box qself. clean ( cx) ,
1288- trait_ : box resolve_type ( cx , trait_path ) ,
1281+ trait_,
12891282 }
12901283 }
12911284 hir:: QPath :: TypeRelative ( ref qself, ref segment) => {
@@ -1296,12 +1289,13 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
12961289 ty:: Error ( _) => return Type :: Infer ,
12971290 _ => bug ! ( "clean: expected associated type, found `{:?}`" , ty) ,
12981291 } ;
1299- let trait_path = hir:: Path { span, res, segments : & [ ] } . clean ( cx) ;
1292+ let trait_ = hir:: Path { span, res, segments : & [ ] } . clean ( cx) ;
1293+ register_res ( cx, trait_. res ) ;
13001294 Type :: QPath {
13011295 name : segment. ident . name ,
13021296 self_def_id : res. opt_def_id ( ) ,
13031297 self_type : box qself. clean ( cx) ,
1304- trait_ : box resolve_type ( cx , trait_path ) ,
1298+ trait_,
13051299 }
13061300 }
13071301 hir:: QPath :: LangItem ( ..) => bug ! ( "clean: requiring documentation of lang item" ) ,
@@ -1470,10 +1464,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14701464 let empty = cx. tcx . intern_substs ( & [ ] ) ;
14711465 let path = external_path ( cx, did, false , vec ! [ ] , empty) ;
14721466 inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1473- let bound = PolyTrait {
1474- trait_ : ResolvedPath { path, did } ,
1475- generic_params : Vec :: new ( ) ,
1476- } ;
1467+ let bound = PolyTrait { trait_ : path, generic_params : Vec :: new ( ) } ;
14771468 bounds. push ( bound) ;
14781469 }
14791470
@@ -1486,10 +1477,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
14861477 }
14871478
14881479 let path = external_path ( cx, did, false , bindings, substs) ;
1489- bounds. insert (
1490- 0 ,
1491- PolyTrait { trait_ : ResolvedPath { path, did } , generic_params : Vec :: new ( ) } ,
1492- ) ;
1480+ bounds. insert ( 0 , PolyTrait { trait_ : path, generic_params : Vec :: new ( ) } ) ;
14931481
14941482 DynTrait ( bounds, lifetime)
14951483 }
@@ -1728,11 +1716,7 @@ impl Clean<Variant> for hir::VariantData<'_> {
17281716
17291717impl Clean < Path > for hir:: Path < ' _ > {
17301718 fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Path {
1731- Path {
1732- global : self . is_global ( ) ,
1733- res : self . res ,
1734- segments : if self . is_global ( ) { & self . segments [ 1 ..] } else { & self . segments } . clean ( cx) ,
1735- }
1719+ Path { res : self . res , segments : self . segments . clean ( cx) }
17361720 }
17371721}
17381722
@@ -1898,7 +1882,7 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
18981882
18991883 // If this impl block is an implementation of the Deref trait, then we
19001884 // need to try inlining the target's inherent impl blocks as well.
1901- if trait_. def_id ( ) == tcx. lang_items ( ) . deref_trait ( ) {
1885+ if trait_. as_ref ( ) . map ( |t| t . def_id ( ) ) == tcx. lang_items ( ) . deref_trait ( ) {
19021886 build_deref_target_impls ( cx, & items, & mut ret) ;
19031887 }
19041888
@@ -1907,7 +1891,7 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
19071891 DefKind :: TyAlias => Some ( tcx. type_of ( did) . clean ( cx) ) ,
19081892 _ => None ,
19091893 } ) ;
1910- let mut make_item = |trait_ : Option < Type > , for_ : Type , items : Vec < Item > | {
1894+ let mut make_item = |trait_ : Option < Path > , for_ : Type , items : Vec < Item > | {
19111895 let kind = ImplItem ( Impl {
19121896 span : types:: rustc_span ( tcx. hir ( ) . local_def_id ( hir_id) . to_def_id ( ) , tcx) ,
19131897 unsafety : impl_. unsafety ,
0 commit comments