diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index fcb25f7aef3d4..967076779add0 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -470,7 +470,6 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R { default_passes = false; passes = vec![ - String::from("strip-hidden"), String::from("collapse-docs"), String::from("unindent-comments"), ]; diff --git a/src/librustdoc/passes/mod.rs b/src/librustdoc/passes/mod.rs index 77d97c84c99bf..3e15d3d3007ac 100644 --- a/src/librustdoc/passes/mod.rs +++ b/src/librustdoc/passes/mod.rs @@ -184,6 +184,15 @@ impl<'a> fold::DocFolder for ImplStripper<'a> { return None; } } + if let Some(generics) = imp.trait_.as_ref().and_then(|t| t.generics()) { + for typaram in generics { + if let Some(did) = typaram.def_id() { + if did.is_local() && !self.retained.contains(&did) { + return None; + } + } + } + } } self.fold_item_recur(i) } diff --git a/src/test/rustdoc/issue-46380-2.rs b/src/test/rustdoc/issue-46380-2.rs new file mode 100644 index 0000000000000..22408d3522a4b --- /dev/null +++ b/src/test/rustdoc/issue-46380-2.rs @@ -0,0 +1,19 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub trait PublicTrait {} + +// @has issue_46380_2/struct.PublicStruct.html +pub struct PublicStruct; + +// @!has - '//*[@class="impl"]' 'impl PublicTrait for PublicStruct' +impl PublicTrait for PublicStruct {} + +struct PrivateStruct; diff --git a/src/test/rustdoc/issue-46380.rs b/src/test/rustdoc/issue-46380.rs new file mode 100644 index 0000000000000..85f29ec4b02d1 --- /dev/null +++ b/src/test/rustdoc/issue-46380.rs @@ -0,0 +1,15 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: --document-private-items + +// @has issue_46380/struct.Hidden.html +#[doc(hidden)] +pub struct Hidden;