about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGary Guo <gary@garyguo.net>2020-08-07 23:34:44 +0100
committerGary Guo <gary@garyguo.net>2020-08-07 23:41:07 +0100
commit505d157814ba4e7d3ee0d036832008c3221b3df4 (patch)
tree872c66d5825b8e82614da0c5a217162e98206b81
parent63c0d9ca51bb471189a0d5529c8ee5491fb4e102 (diff)
downloadrust-505d157814ba4e7d3ee0d036832008c3221b3df4.tar.gz
rust-505d157814ba4e7d3ee0d036832008c3221b3df4.zip
Display elided lifetime for external paths
-rw-r--r--src/librustdoc/clean/utils.rs11
-rw-r--r--src/test/rustdoc/elided-lifetime.rs13
2 files changed, 20 insertions, 4 deletions
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</a>&lt;'_"
+pub fn test5(a: &Option<u32>) -> std::option::Iter<u32> {
+    a.iter()
+}
+
+// @has foo/fn.test6.html
+// @matches - "Iter</a>&lt;'_"
+pub fn test6(a: &Option<u32>) -> std::option::Iter<'_, u32> {
+    a.iter()
+}