diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 52c30668826..adef4c83224 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -2,9 +2,9 @@ use crate::clean::auto_trait::AutoTraitFinder; use crate::clean::blanket_impl::BlanketImplFinder; use crate::clean::{ inline, Clean, Crate, Deprecation, ExternalCrate, FnDecl, FnRetTy, Generic, GenericArg, - GenericArgs, GenericBound, Generics, GetDefId, ImportSource, Item, ItemEnum, MacroKind, Path, - PathSegment, Primitive, PrimitiveType, ResolvedPath, Span, Stability, Type, TypeBinding, - TypeKind, Visibility, WherePredicate, + GenericArgs, GenericBound, Generics, GetDefId, ImportSource, Item, ItemEnum, Lifetime, + MacroKind, Path, PathSegment, Primitive, PrimitiveType, ResolvedPath, Span, Stability, Type, + TypeBinding, TypeKind, Visibility, WherePredicate, }; use crate::core::DocContext; @@ -121,7 +121,10 @@ pub fn external_generic_args( let args: Vec<_> = substs .iter() .filter_map(|kind| match kind.unpack() { - GenericArgKind::Lifetime(lt) => lt.clean(cx).map(GenericArg::Lifetime), + GenericArgKind::Lifetime(lt) => match lt { + ty::ReLateBound(_, ty::BrAnon(_)) => Some(GenericArg::Lifetime(Lifetime::elided())), + _ => lt.clean(cx).map(GenericArg::Lifetime), + }, GenericArgKind::Type(_) if skip_self => { skip_self = false; None diff --git a/src/test/rustdoc/elided-lifetime.rs b/src/test/rustdoc/elided-lifetime.rs index 641866aaf3c..6ba58380ed5 100644 --- a/src/test/rustdoc/elided-lifetime.rs +++ b/src/test/rustdoc/elided-lifetime.rs @@ -31,3 +31,16 @@ pub fn test3(a: &u32) -> ARef { pub fn test4(a: &u32) -> ARef<'_> { Ref(a) } + +// Ensure external paths also display elided lifetime +// @has foo/fn.test5.html +// @matches - "Iter<'_" +pub fn test5(a: &Option) -> std::option::Iter { + a.iter() +} + +// @has foo/fn.test6.html +// @matches - "Iter<'_" +pub fn test6(a: &Option) -> std::option::Iter<'_, u32> { + a.iter() +}