Repository navigation
cross-crate #[doc(hidden)] is ignored when listing trait implementations #86448
Copy link
Copy link
Closed
Labels
A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crateArea: Documentation that has been re-exported from a different crateC-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
Context
https://users.rust-lang.org/t/hidden-trait-implementation-in-online-docs/61256/4
Repro
set -euo pipefail
cd $(mktemp -d)
cargo new -q --lib dependency
cat> dependency/src/lib.rs <<'EOF'
#[doc(hidden)]
pub enum HiddenType {}
pub enum MyLibType {}
impl From<HiddenType> for MyLibType {
fn from (it: HiddenType)
-> MyLibType
{
match it {}
}
}
EOF
(cd dependency
set -x
cargo doc -q --no-deps
# No matches
! grep -o HiddenType target/doc/dependency/index.html
)
cargo init -q --lib --name mylib
cat> src/lib.rs <<'EOF'
pub use ::dependency::HiddenType; // OK, not re-exported
pub enum MyLibType {}
impl From<HiddenType> for MyLibType {
fn from (it: HiddenType)
-> MyLibType
{
match it {}
}
}
EOF
cat>> Cargo.toml <<'EOF'
dependency.path = 'dependency'
EOF
set -x
cargo doc -q --no-deps
# No matches
! grep -o HiddenType target/doc/mylib/index.html
# There are matches
grep -o HiddenType target/doc/mylib/enum.MyLibType.html-
Last line yields several occurrences of
HiddenTypein the generated.htmlfile.Expected behavior
No occurrences of
HiddenTypeanywhere since it was#[doc(hidden)]
@rustbot label C-bug T-rustdoc
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crateArea: Documentation that has been re-exported from a different crateC-bugCategory: This is a bug.Category: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Activity
jyn514 commentedon Jun 21, 2021
I expect the fix is to check for
doc(hidden)just afterrust/src/librustdoc/clean/inline.rs
Line 370 in e82b650
fee1-dead commentedon Jun 21, 2021
@rustbot claim
fee1-dead commentedon Jun 21, 2021
cc @jyn514
I checked for doc(hidden) like this:
But it doesn't seem to work, as my test would fail. I also tried using the same way to check for
trait_but it also failed. I noticed that the issue involvesFrom<HiddenType>so I might need to iterate over generic parameters, I cannot find any function that does that inTyCtxt, so can someone point me in the right direction? Thanks :)danielhenrymantilla commentedon Jun 21, 2021
You can look at how the
strip-hidden-itemspass works:rust/src/librustdoc/passes/stripper.rs
Lines 142 to 143 in 0aa2844
jyn514 commentedon Jun 24, 2021
@danielhenrymantilla am I right in understanding this only happens for cross-crate traits, and impls for hidden traits in the same crate are still hidden? In other words, #86513 just makes the cross-crate case consistent?
danielhenrymantilla commentedon Jun 24, 2021
I believe so, yes: the
strip-hidden-itemspass was already taking care of such cases for local#[doc(hidden)]types. FWIW, the thing that motivated this discussion was noticing aFrom<Unique<T>> for ptr::NonNull<T>leaking on the docs for::std, but not on the ones for::coreRollup merge of rust-lang#86513 - fee1-dead:cross-crate-doc-hidden, r…
Rollup merge of rust-lang#86513 - fee1-dead:cross-crate-doc-hidden, r…