Skip to content

#[doc(hidden)] doesn't work on module or crate re-exports #83939

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
jplatte opened this issue Apr 6, 2021 · 6 comments
Closed

#[doc(hidden)] doesn't work on module or crate re-exports #83939

jplatte opened this issue Apr 6, 2021 · 6 comments
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@jplatte
Copy link
Contributor

jplatte commented Apr 6, 2021

Minimal reproduction:

mod foo {
    pub mod bar {}
}

#[doc(hidden)]
pub use foo::bar;

#[doc(hidden)]
pub use std as _std;

I expected to see this happen: No docs for the #[doc(hidden)] re-exports

Instead, this happened: Both re-exports show up in the generated doc page

Meta

rustc --version --verbose:

rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1

rustc +nightly --version --verbose:

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0
@jplatte jplatte added the C-bug Category: This is a bug. label Apr 6, 2021
@jonas-schievink jonas-schievink added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 6, 2021
@jplatte
Copy link
Contributor Author

jplatte commented Apr 6, 2021

Luckily, there is an easy workaround: a #[doc(hidden)] module containing pub use thing_to_be_reexported::*;.

@jplatte jplatte changed the title #[doc(hidden)] doesn't work on module re-exports #[doc(hidden)] doesn't work on module or crate re-exports Apr 6, 2021
@jyn514
Copy link
Member

jyn514 commented Apr 6, 2021

@jplatte your example doesn't compile:

error[E0365]: `foo` is private, and cannot be re-exported
 --> inline.rs:6:9
  |
6 | pub use foo as bar;
  |         ^^^^^^^^^^ re-export of private `foo`
  |
  = note: consider declaring type or module `foo` with `pub`

error: extern crate `std` is private, and cannot be re-exported (error E0365), consider declaring with `pub`
 --> inline.rs:9:9
  |
9 | pub use std as _std;
  |         ^^^^^^^^^^^
  |
  = note: `#[deny(pub_use_of_private_extern_crate)]` on by default
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>

@jyn514 jyn514 added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Apr 6, 2021
@jplatte
Copy link
Contributor Author

jplatte commented Apr 6, 2021

Sorry, fixed the module part of the example. But re-exporting an external crate should always work, no? Is that error new?

@jyn514
Copy link
Member

jyn514 commented Apr 6, 2021

@jplatte now it compiles, but rustdoc hides all the examples as I'd expect:
image

$ rustdoc --version
rustdoc 1.53.0-nightly (138fd56cf 2021-04-02)

But re-exporting an external crate should always work, no? Is that error new?

See #34537, I don't have opinions. Rustdoc doesn't emit that lint which I consider a bug, working on a PR for that now.

@jyn514
Copy link
Member

jyn514 commented Apr 6, 2021

See #34537, I don't have opinions. Rustdoc doesn't emit that lint which I consider a bug, working on a PR for that now.

Oh, it turns out this is already a hard error on nightly: #80763

@jplatte
Copy link
Contributor Author

jplatte commented Apr 7, 2021

Okay, found out why my minimum example is wrong: This bug needs another re-export level to trigger. So I guess it's a duplicate of #53417.

@jplatte jplatte closed this as completed Apr 7, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants