Skip to content

Commit 662f902

Browse files
authored
Rollup merge of #46412 - chrisduerr:issue-46380, r=QuietMisdreavus
Hide private trait type params and show hidden items with document-private As discussed in #46380, this PR removes the `strip-hidden` pass from `--document-private-items` which allows showing `#[doc(hidden)]` with rustdoc. The second commit removes the trait implementation from the docs if the trait's parameter is private.
2 parents 3f99b7c + 5f47c7f commit 662f902

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

src/librustdoc/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,6 @@ where R: 'static + Send, F: 'static + Send + FnOnce(Output) -> R {
470470
default_passes = false;
471471

472472
passes = vec![
473-
String::from("strip-hidden"),
474473
String::from("collapse-docs"),
475474
String::from("unindent-comments"),
476475
];

src/librustdoc/passes/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,15 @@ impl<'a> fold::DocFolder for ImplStripper<'a> {
184184
return None;
185185
}
186186
}
187+
if let Some(generics) = imp.trait_.as_ref().and_then(|t| t.generics()) {
188+
for typaram in generics {
189+
if let Some(did) = typaram.def_id() {
190+
if did.is_local() && !self.retained.contains(&did) {
191+
return None;
192+
}
193+
}
194+
}
195+
}
187196
}
188197
self.fold_item_recur(i)
189198
}

src/test/rustdoc/issue-46380-2.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub trait PublicTrait<T> {}
12+
13+
// @has issue_46380_2/struct.PublicStruct.html
14+
pub struct PublicStruct;
15+
16+
// @!has - '//*[@class="impl"]' 'impl PublicTrait<PrivateStruct> for PublicStruct'
17+
impl PublicTrait<PrivateStruct> for PublicStruct {}
18+
19+
struct PrivateStruct;

src/test/rustdoc/issue-46380.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags: --document-private-items
12+
13+
// @has issue_46380/struct.Hidden.html
14+
#[doc(hidden)]
15+
pub struct Hidden;

0 commit comments

Comments
 (0)