Skip to content

cross-crate #[doc(hidden)] is ignored when listing trait implementations #86448

Closed
@danielhenrymantilla

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 HiddenType in the generated .html file.

    Expected behavior

    No occurrences of HiddenType anywhere since it was #[doc(hidden)]

  • Playground

@rustbot label C-bug T-rustdoc

cc @GuillaumeGomez

Metadata

Assignees

Labels

A-cross-crate-reexportsArea: Documentation that has been re-exported from a different crateC-bugCategory: This is a bug.E-easyCall 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.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions