-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Description
I tried this code:
mod foo {
pub struct S;
}
use foo::S;
pub type A = S;
impl Default for A {
fn default() -> Self {
S
}
}
impl A {
pub fn a(&self) {}
}I expected the documentation for the type alias A to show the method fn a(&self) and the implementation of Default.
Instead, the type alias does not show the method fn a(&self). It does however show the implementation of Default.
Workarounds
By publicly exposing foo::S through pub use foo::S, the documentation of fn a(&self) on the alias is documented as I expected, but then foo:S is publicly reachable, which in my case is unwanted due to being an internal implementation detail.
This also works when making the use statement #[doc(hidden)], which gets the docs to look like I expected them to.
mod foo {
pub struct S;
}
#[doc(hidden)]
pub use foo::S;
pub type A = S;
impl Default for A {
fn default() -> Self {
S
}
}
impl A {
pub fn a(&self) {}
}Meta
rustc --version --verbose:
cargo 1.74.1 (ecb9851af 2023-10-18)
release: 1.74.1
commit-hash: ecb9851afd3095e988daaa35a48bc7f3cb748e04
commit-date: 2023-10-18
host: x86_64-unknown-linux-gnu
libgit2: 1.7.1 (sys:0.18.0 vendored)
libcurl: 8.4.0-DEV (sys:0.4.68+curl-8.4.0 vendored ssl:OpenSSL/1.1.1u)
ssl: OpenSSL 1.1.1u 30 May 2023
os: Arch Linux [64-bit]
Thanks @GuillaumeGomez for helping me figure out why what I was expecting wasn't happening though it looked like it should.

