@@ -152,8 +152,8 @@ impl Clean<GenericBound> for hir::GenericBound<'_> {
152
152
}
153
153
}
154
154
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 {
157
157
let ( trait_ref, bounds) = * self ;
158
158
let kind = cx. tcx . def_kind ( trait_ref. def_id ) . into ( ) ;
159
159
if !matches ! ( kind, ItemType :: Trait | ItemType :: TraitAlias ) {
@@ -168,16 +168,13 @@ impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
168
168
169
169
debug ! ( "ty::TraitRef\n subst: {:?}\n " , trait_ref. substs) ;
170
170
171
- ResolvedPath { path, did : trait_ref . def_id }
171
+ path
172
172
}
173
173
}
174
174
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)
181
178
}
182
179
}
183
180
@@ -384,16 +381,13 @@ impl<'tcx> Clean<WherePredicate> for ty::ProjectionPredicate<'tcx> {
384
381
impl < ' tcx > Clean < Type > for ty:: ProjectionTy < ' tcx > {
385
382
fn clean ( & self , cx : & mut DocContext < ' _ > ) -> Type {
386
383
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) ;
391
385
let self_type = self . self_ty ( ) . clean ( cx) ;
392
386
Type :: QPath {
393
387
name : cx. tcx . associated_item ( self . item_def_id ) . ident . name ,
394
388
self_def_id : self_type. def_id ( ) ,
395
389
self_type : box self_type,
396
- trait_ : box trait_ ,
390
+ trait_,
397
391
}
398
392
}
399
393
}
@@ -896,10 +890,11 @@ impl Clean<bool> for hir::IsAuto {
896
890
}
897
891
}
898
892
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 {
901
895
let path = self . path . clean ( cx) ;
902
- resolve_type ( cx, path)
896
+ register_res ( cx, path. res ) ;
897
+ path
903
898
}
904
899
}
905
900
@@ -1105,9 +1100,8 @@ impl Clean<Item> for ty::AssocItem {
1105
1100
if * name != my_name {
1106
1101
return None ;
1107
1102
}
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 ;
1111
1105
}
1112
1106
match * * self_type {
1113
1107
Generic ( ref s) if * s == kw:: SelfUpper => { }
@@ -1273,19 +1267,18 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
1273
1267
return normalized_value. clean ( cx) ;
1274
1268
}
1275
1269
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 ] ;
1278
1271
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 {
1281
1273
res : Res :: Def ( DefKind :: Trait , trait_def) ,
1282
1274
segments : trait_segments. clean ( cx) ,
1283
1275
} ;
1276
+ register_res ( cx, trait_. res ) ;
1284
1277
Type :: QPath {
1285
1278
name : p. segments . last ( ) . expect ( "segments were empty" ) . ident . name ,
1286
1279
self_def_id : Some ( DefId :: local ( qself. hir_id . owner . local_def_index ) ) ,
1287
1280
self_type : box qself. clean ( cx) ,
1288
- trait_ : box resolve_type ( cx , trait_path ) ,
1281
+ trait_,
1289
1282
}
1290
1283
}
1291
1284
hir:: QPath :: TypeRelative ( ref qself, ref segment) => {
@@ -1296,12 +1289,13 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
1296
1289
ty:: Error ( _) => return Type :: Infer ,
1297
1290
_ => bug ! ( "clean: expected associated type, found `{:?}`" , ty) ,
1298
1291
} ;
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 ) ;
1300
1294
Type :: QPath {
1301
1295
name : segment. ident . name ,
1302
1296
self_def_id : res. opt_def_id ( ) ,
1303
1297
self_type : box qself. clean ( cx) ,
1304
- trait_ : box resolve_type ( cx , trait_path ) ,
1298
+ trait_,
1305
1299
}
1306
1300
}
1307
1301
hir:: QPath :: LangItem ( ..) => bug ! ( "clean: requiring documentation of lang item" ) ,
@@ -1470,10 +1464,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1470
1464
let empty = cx. tcx . intern_substs ( & [ ] ) ;
1471
1465
let path = external_path ( cx, did, false , vec ! [ ] , empty) ;
1472
1466
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 ( ) } ;
1477
1468
bounds. push ( bound) ;
1478
1469
}
1479
1470
@@ -1486,10 +1477,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1486
1477
}
1487
1478
1488
1479
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 ( ) } ) ;
1493
1481
1494
1482
DynTrait ( bounds, lifetime)
1495
1483
}
@@ -1728,11 +1716,7 @@ impl Clean<Variant> for hir::VariantData<'_> {
1728
1716
1729
1717
impl Clean < Path > for hir:: Path < ' _ > {
1730
1718
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) }
1736
1720
}
1737
1721
}
1738
1722
@@ -1898,7 +1882,7 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
1898
1882
1899
1883
// If this impl block is an implementation of the Deref trait, then we
1900
1884
// 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 ( ) {
1902
1886
build_deref_target_impls ( cx, & items, & mut ret) ;
1903
1887
}
1904
1888
@@ -1907,7 +1891,7 @@ fn clean_impl(impl_: &hir::Impl<'_>, hir_id: hir::HirId, cx: &mut DocContext<'_>
1907
1891
DefKind :: TyAlias => Some ( tcx. type_of ( did) . clean ( cx) ) ,
1908
1892
_ => None ,
1909
1893
} ) ;
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 > | {
1911
1895
let kind = ImplItem ( Impl {
1912
1896
span : types:: rustc_span ( tcx. hir ( ) . local_def_id ( hir_id) . to_def_id ( ) , tcx) ,
1913
1897
unsafety : impl_. unsafety ,
0 commit comments