Skip to content

Commit 576661c

Browse files
committed
Rustdoc fallout.
1 parent 7437136 commit 576661c

File tree

2 files changed

+35
-32
lines changed

2 files changed

+35
-32
lines changed

src/librustdoc/clean/mod.rs

+32-26
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,15 @@ impl<'tcx> Clean<'tcx, Option<Lifetime>> for ty::Region<'tcx> {
222222
match **self {
223223
ty::ReStatic => Some(Lifetime::statik()),
224224
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+
}
226233
}
227-
ty::ReEarlyBound(ref data) => Some(Lifetime(data.name)),
228-
229234
ty::ReLateBound(..)
230235
| ty::ReFree(..)
231236
| ty::ReVar(..)
@@ -530,29 +535,25 @@ fn clean_generic_param<'tcx>(
530535
GenericParamDef { name, kind }
531536
}
532537

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+
533555
impl<'tcx> Clean<'tcx, Generics> for hir::Generics<'tcx> {
534556
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-
556557
let impl_trait_params = self
557558
.params
558559
.iter()
@@ -991,6 +992,7 @@ impl<'tcx> Clean<'tcx, PolyTrait> for hir::PolyTraitRef<'tcx> {
991992
generic_params: self
992993
.bound_generic_params
993994
.iter()
995+
.filter(|p| !is_elided_lifetime(p))
994996
.map(|x| clean_generic_param(cx, None, x))
995997
.collect(),
996998
}
@@ -1865,8 +1867,12 @@ impl<'tcx> Clean<'tcx, BareFunctionDecl> for hir::BareFnTy<'tcx> {
18651867
fn clean(&self, cx: &mut DocContext<'tcx>) -> BareFunctionDecl {
18661868
let (generic_params, decl) = enter_impl_trait(cx, |cx| {
18671869
// 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();
18701876
let args = clean_args_from_types_and_names(cx, self.decl.inputs, self.param_names);
18711877
let decl = clean_fn_decl_with_args(cx, self.decl, args);
18721878
(generic_params, decl)

src/librustdoc/clean/utils.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,9 @@ pub(crate) fn substs_to_args<'tcx>(
8484
let mut ret_val =
8585
Vec::with_capacity(substs.len().saturating_sub(if skip_first { 1 } else { 0 }));
8686
ret_val.extend(substs.iter().filter_map(|kind| match kind.unpack() {
87-
GenericArgKind::Lifetime(lt) => match *lt {
88-
ty::ReLateBound(_, ty::BoundRegion { kind: ty::BrAnon(_), .. }) => {
89-
Some(GenericArg::Lifetime(Lifetime::elided()))
90-
}
91-
_ => lt.clean(cx).map(GenericArg::Lifetime),
92-
},
87+
GenericArgKind::Lifetime(lt) => {
88+
Some(GenericArg::Lifetime(lt.clean(cx).unwrap_or(Lifetime::elided())))
89+
}
9390
GenericArgKind::Type(_) if skip_first => {
9491
skip_first = false;
9592
None

0 commit comments

Comments
 (0)