mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
Display elided lifetime for external paths
This commit is contained in:
parent
63c0d9ca51
commit
505d157814
@ -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
|
||||
|
@ -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</a><'_"
|
||||
pub fn test5(a: &Option<u32>) -> std::option::Iter<u32> {
|
||||
a.iter()
|
||||
}
|
||||
|
||||
// @has foo/fn.test6.html
|
||||
// @matches - "Iter</a><'_"
|
||||
pub fn test6(a: &Option<u32>) -> std::option::Iter<'_, u32> {
|
||||
a.iter()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user