@@ -222,10 +222,15 @@ impl<'tcx> Clean<'tcx, Option<Lifetime>> for ty::Region<'tcx> {
222
222
match * * self {
223
223
ty:: ReStatic => Some ( Lifetime :: statik ( ) ) ,
224
224
ty:: ReLateBound ( _, ty:: BoundRegion { kind : ty:: BrNamed ( _, name) , .. } ) => {
225
- Some ( Lifetime ( name) )
225
+ if name != kw:: UnderscoreLifetime { Some ( Lifetime ( name) ) } else { None }
226
+ }
227
+ ty:: ReEarlyBound ( ref data) => {
228
+ if data. name != kw:: UnderscoreLifetime {
229
+ Some ( Lifetime ( data. name ) )
230
+ } else {
231
+ None
232
+ }
226
233
}
227
- ty:: ReEarlyBound ( ref data) => Some ( Lifetime ( data. name ) ) ,
228
-
229
234
ty:: ReLateBound ( ..)
230
235
| ty:: ReFree ( ..)
231
236
| ty:: ReVar ( ..)
@@ -530,29 +535,25 @@ fn clean_generic_param<'tcx>(
530
535
GenericParamDef { name, kind }
531
536
}
532
537
538
+ /// Synthetic type-parameters are inserted after normal ones.
539
+ /// In order for normal parameters to be able to refer to synthetic ones,
540
+ /// scans them first.
541
+ fn is_impl_trait ( param : & hir:: GenericParam < ' _ > ) -> bool {
542
+ match param. kind {
543
+ hir:: GenericParamKind :: Type { synthetic, .. } => synthetic,
544
+ _ => false ,
545
+ }
546
+ }
547
+
548
+ /// This can happen for `async fn`, e.g. `async fn f<'_>(&'_ self)`.
549
+ ///
550
+ /// See `lifetime_to_generic_param` in `rustc_ast_lowering` for more information.
551
+ fn is_elided_lifetime ( param : & hir:: GenericParam < ' _ > ) -> bool {
552
+ matches ! ( param. kind, hir:: GenericParamKind :: Lifetime { kind: hir:: LifetimeParamKind :: Elided } )
553
+ }
554
+
533
555
impl < ' tcx > Clean < ' tcx , Generics > for hir:: Generics < ' tcx > {
534
556
fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> Generics {
535
- // Synthetic type-parameters are inserted after normal ones.
536
- // In order for normal parameters to be able to refer to synthetic ones,
537
- // scans them first.
538
- fn is_impl_trait ( param : & hir:: GenericParam < ' _ > ) -> bool {
539
- match param. kind {
540
- hir:: GenericParamKind :: Type { synthetic, .. } => synthetic,
541
- _ => false ,
542
- }
543
- }
544
- /// This can happen for `async fn`, e.g. `async fn f<'_>(&'_ self)`.
545
- ///
546
- /// See [`lifetime_to_generic_param`] in [`rustc_ast_lowering`] for more information.
547
- ///
548
- /// [`lifetime_to_generic_param`]: rustc_ast_lowering::LoweringContext::lifetime_to_generic_param
549
- fn is_elided_lifetime ( param : & hir:: GenericParam < ' _ > ) -> bool {
550
- matches ! (
551
- param. kind,
552
- hir:: GenericParamKind :: Lifetime { kind: hir:: LifetimeParamKind :: Elided }
553
- )
554
- }
555
-
556
557
let impl_trait_params = self
557
558
. params
558
559
. iter ( )
@@ -991,6 +992,7 @@ impl<'tcx> Clean<'tcx, PolyTrait> for hir::PolyTraitRef<'tcx> {
991
992
generic_params : self
992
993
. bound_generic_params
993
994
. iter ( )
995
+ . filter ( |p| !is_elided_lifetime ( p) )
994
996
. map ( |x| clean_generic_param ( cx, None , x) )
995
997
. collect ( ) ,
996
998
}
@@ -1865,8 +1867,12 @@ impl<'tcx> Clean<'tcx, BareFunctionDecl> for hir::BareFnTy<'tcx> {
1865
1867
fn clean ( & self , cx : & mut DocContext < ' tcx > ) -> BareFunctionDecl {
1866
1868
let ( generic_params, decl) = enter_impl_trait ( cx, |cx| {
1867
1869
// NOTE: generics must be cleaned before args
1868
- let generic_params =
1869
- self . generic_params . iter ( ) . map ( |x| clean_generic_param ( cx, None , x) ) . collect ( ) ;
1870
+ let generic_params = self
1871
+ . generic_params
1872
+ . iter ( )
1873
+ . filter ( |p| !is_elided_lifetime ( p) )
1874
+ . map ( |x| clean_generic_param ( cx, None , x) )
1875
+ . collect ( ) ;
1870
1876
let args = clean_args_from_types_and_names ( cx, self . decl . inputs , self . param_names ) ;
1871
1877
let decl = clean_fn_decl_with_args ( cx, self . decl , args) ;
1872
1878
( generic_params, decl)
0 commit comments