From 3ac1a9b50d95fd2665069c512d2b09b6edfc554f Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Mon, 4 Jul 2022 22:19:53 -0700 Subject: [PATCH] rustdoc: filter '_ lifetimes from ty::Generics Fixes a weirdly-rendered section of the std::string::String docs. --- src/librustdoc/clean/mod.rs | 1 + .../issue-98697-reexport-with-anonymous-lifetime.rs | 8 ++++++++ src/test/rustdoc/issue-98697.rs | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 6ee725edcfc1d..4d33b7a376a23 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -629,6 +629,7 @@ fn clean_ty_generics<'tcx>( .params .iter() .filter_map(|param| match param.kind { + ty::GenericParamDefKind::Lifetime if param.name == kw::UnderscoreLifetime => None, ty::GenericParamDefKind::Lifetime => Some(param.clean(cx)), ty::GenericParamDefKind::Type { synthetic, .. } => { if param.name == kw::SelfUpper { diff --git a/src/test/rustdoc/auxiliary/issue-98697-reexport-with-anonymous-lifetime.rs b/src/test/rustdoc/auxiliary/issue-98697-reexport-with-anonymous-lifetime.rs index 22cbeae72662a..4e55e7ed57630 100644 --- a/src/test/rustdoc/auxiliary/issue-98697-reexport-with-anonymous-lifetime.rs +++ b/src/test/rustdoc/auxiliary/issue-98697-reexport-with-anonymous-lifetime.rs @@ -7,3 +7,11 @@ where { unimplemented!() } + +pub struct Extra; + +pub trait MyTrait { + fn run() {} +} + +impl MyTrait<&Extra> for Extra {} diff --git a/src/test/rustdoc/issue-98697.rs b/src/test/rustdoc/issue-98697.rs index 25ab55acd7747..83e08094c0953 100644 --- a/src/test/rustdoc/issue-98697.rs +++ b/src/test/rustdoc/issue-98697.rs @@ -11,3 +11,7 @@ extern crate issue_98697_reexport_with_anonymous_lifetime; // @has issue_98697/fn.repro.html '//pre[@class="rust fn"]/code' 'fn repro() where F: Fn(&str)' // @!has issue_98697/fn.repro.html '//pre[@class="rust fn"]/code' 'for<' pub use issue_98697_reexport_with_anonymous_lifetime::repro; + +// @has issue_98697/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl MyTrait<&Extra> for Extra' +// @!has issue_98697/struct.Extra.html '//div[@id="trait-implementations-list"]//h3[@class="code-header in-band"]' 'impl<' +pub use issue_98697_reexport_with_anonymous_lifetime::Extra;