@@ -1322,14 +1322,17 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
1322
1322
let trait_def = cx. tcx . associated_item ( p. res . def_id ( ) ) . container_id ( cx. tcx ) ;
1323
1323
let trait_ = self :: Path {
1324
1324
res : Res :: Def ( DefKind :: Trait , trait_def) ,
1325
- segments : trait_segments. iter ( ) . map ( |x| x . clean ( cx) ) . collect ( ) ,
1325
+ segments : trait_segments. iter ( ) . map ( |x| clean_path_segment ( x , cx) ) . collect ( ) ,
1326
1326
} ;
1327
1327
register_res ( cx, trait_. res ) ;
1328
1328
let self_def_id = DefId :: local ( qself. hir_id . owner . local_def_index ) ;
1329
1329
let self_type = clean_ty ( qself, cx) ;
1330
1330
let should_show_cast = compute_should_show_cast ( Some ( self_def_id) , & trait_, & self_type) ;
1331
1331
Type :: QPath {
1332
- assoc : Box :: new ( p. segments . last ( ) . expect ( "segments were empty" ) . clean ( cx) ) ,
1332
+ assoc : Box :: new ( clean_path_segment (
1333
+ p. segments . last ( ) . expect ( "segments were empty" ) ,
1334
+ cx,
1335
+ ) ) ,
1333
1336
should_show_cast,
1334
1337
self_type : Box :: new ( self_type) ,
1335
1338
trait_,
@@ -1349,7 +1352,7 @@ fn clean_qpath<'tcx>(hir_ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> Type
1349
1352
let self_type = clean_ty ( qself, cx) ;
1350
1353
let should_show_cast = compute_should_show_cast ( self_def_id, & trait_, & self_type) ;
1351
1354
Type :: QPath {
1352
- assoc : Box :: new ( segment . clean ( cx) ) ,
1355
+ assoc : Box :: new ( clean_path_segment ( segment , cx) ) ,
1353
1356
should_show_cast,
1354
1357
self_type : Box :: new ( self_type) ,
1355
1358
trait_,
@@ -1507,7 +1510,7 @@ pub(crate) fn clean_ty<'tcx>(ty: &hir::Ty<'tcx>, cx: &mut DocContext<'tcx>) -> T
1507
1510
if !lifetime. is_elided ( ) { Some ( clean_lifetime ( * lifetime, cx) ) } else { None } ;
1508
1511
DynTrait ( bounds, lifetime)
1509
1512
}
1510
- TyKind :: BareFn ( barefn) => BareFunction ( Box :: new ( barefn . clean ( cx) ) ) ,
1513
+ TyKind :: BareFn ( barefn) => BareFunction ( Box :: new ( clean_bare_fn_ty ( barefn , cx) ) ) ,
1511
1514
// Rustdoc handles `TyKind::Err`s by turning them into `Type::Infer`s.
1512
1515
TyKind :: Infer | TyKind :: Err => Infer ,
1513
1516
TyKind :: Typeof ( ..) => panic ! ( "unimplemented type {:?}" , ty. kind) ,
@@ -1823,7 +1826,10 @@ fn clean_variant_data<'tcx>(
1823
1826
}
1824
1827
1825
1828
fn clean_path < ' tcx > ( path : & hir:: Path < ' tcx > , cx : & mut DocContext < ' tcx > ) -> Path {
1826
- Path { res : path. res , segments : path. segments . iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) }
1829
+ Path {
1830
+ res : path. res ,
1831
+ segments : path. segments . iter ( ) . map ( |x| clean_path_segment ( x, cx) ) . collect ( ) ,
1832
+ }
1827
1833
}
1828
1834
1829
1835
fn clean_generic_args < ' tcx > (
@@ -1861,28 +1867,30 @@ fn clean_generic_args<'tcx>(
1861
1867
}
1862
1868
}
1863
1869
1864
- impl < ' tcx > Clean < ' tcx , PathSegment > for hir:: PathSegment < ' tcx > {
1865
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> PathSegment {
1866
- PathSegment { name : self . ident . name , args : clean_generic_args ( self . args ( ) , cx) }
1867
- }
1870
+ fn clean_path_segment < ' tcx > (
1871
+ path : & hir:: PathSegment < ' tcx > ,
1872
+ cx : & mut DocContext < ' tcx > ,
1873
+ ) -> PathSegment {
1874
+ PathSegment { name : path. ident . name , args : clean_generic_args ( path. args ( ) , cx) }
1868
1875
}
1869
1876
1870
- impl < ' tcx > Clean < ' tcx , BareFunctionDecl > for hir:: BareFnTy < ' tcx > {
1871
- fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> BareFunctionDecl {
1872
- let ( generic_params, decl) = enter_impl_trait ( cx, |cx| {
1873
- // NOTE: generics must be cleaned before args
1874
- let generic_params = self
1875
- . generic_params
1876
- . iter ( )
1877
- . filter ( |p| !is_elided_lifetime ( p) )
1878
- . map ( |x| clean_generic_param ( cx, None , x) )
1879
- . collect ( ) ;
1880
- let args = clean_args_from_types_and_names ( cx, self . decl . inputs , self . param_names ) ;
1881
- let decl = clean_fn_decl_with_args ( cx, self . decl , args) ;
1882
- ( generic_params, decl)
1883
- } ) ;
1884
- BareFunctionDecl { unsafety : self . unsafety , abi : self . abi , decl, generic_params }
1885
- }
1877
+ fn clean_bare_fn_ty < ' tcx > (
1878
+ bare_fn : & hir:: BareFnTy < ' tcx > ,
1879
+ cx : & mut DocContext < ' tcx > ,
1880
+ ) -> BareFunctionDecl {
1881
+ let ( generic_params, decl) = enter_impl_trait ( cx, |cx| {
1882
+ // NOTE: generics must be cleaned before args
1883
+ let generic_params = bare_fn
1884
+ . generic_params
1885
+ . iter ( )
1886
+ . filter ( |p| !is_elided_lifetime ( p) )
1887
+ . map ( |x| clean_generic_param ( cx, None , x) )
1888
+ . collect ( ) ;
1889
+ let args = clean_args_from_types_and_names ( cx, bare_fn. decl . inputs , bare_fn. param_names ) ;
1890
+ let decl = clean_fn_decl_with_args ( cx, bare_fn. decl , args) ;
1891
+ ( generic_params, decl)
1892
+ } ) ;
1893
+ BareFunctionDecl { unsafety : bare_fn. unsafety , abi : bare_fn. abi , decl, generic_params }
1886
1894
}
1887
1895
1888
1896
fn clean_maybe_renamed_item < ' tcx > (
0 commit comments