Skip to content

Documentation of a re-export doesn't appear on level-two re-export #81893

@jplatte

Description

@jplatte
Contributor

I have a macro crate with a "peer dependency" on another crate, i.e. I can't write doctests for the macro itself without introducing circular dev-dependencies which are kind of annoying. The other crate re-exports the macro and the macro is actually expected to only ever be used through there, so I documented the re-export instead. However, there's another higher-level crate that re-exports a bunch of other crates entirely including the one that re-exports the macro. In the documentation of the higher-level crate, the documentation for the macro does not appear, while it appears on the "level-one" re-export.

Minimal reproduction:

Crate foo re-exports a type from bar, which is itself a re-export of a type from baz. The docs on each of the declarations (original type definition in baz, re-exports in bar and foo) are simply the crate name

// # baz/src/lib.rs
/// baz
pub struct Type;

// # bar/src/lib.rs
/// bar
pub use baz::Type;

// # foo/src/lib.rs
/// foo
pub use bar::Type;

Here is a repo with this: https://github.com/jplatte/rust-issue-81893

I expected to see this happen: the docs of foo::Type should be foo bar baz

Instead, this happened: the docs of foo::Type are foo baz

Meta

Happens with latest nightly from rustup that has rustfmt:

rustc --version --verbose:

rustc 1.51.0-nightly (04caa632d 2021-01-30)
binary: rustc
commit-hash: 04caa632dd10c2bf64b69524c7f9c4c30a436877
commit-date: 2021-01-30
host: x86_64-unknown-linux-gnu
release: 1.51.0-nightly
LLVM version: 11.0.1

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
on Feb 8, 2021
jyn514

jyn514 commented on Feb 9, 2021

@jyn514
Member

Some related bugs:

mod a {
    /// baz
    pub struct Type;
}

mod b {
    /// bar
    pub use crate::a::Type;
}

/// foo
pub use b::Type;

only shows baz in the docs, as does

mod a {
    /// baz
    pub struct Type;
}

/// bar
pub use a::Type;
jyn514

jyn514 commented on Feb 9, 2021

@jyn514
Member

A bit of trivia, not particularly helpful: In 1.33, the cross-crate issue behaved as the single crate issue and only showed baz.

TaKO8Ki

TaKO8Ki commented on Feb 15, 2021

@TaKO8Ki
Member

@rustbot claim

TaKO8Ki

TaKO8Ki commented on Mar 9, 2021

@TaKO8Ki
Member

It is about work on this issue!

jyn514

jyn514 commented on Apr 2, 2021

@jyn514
Member

@TaKO8Ki hi, have you made any progress on this issue? No problem if not, but please comment @rustbot release-assignment if so, so other people can work on it.

TaKO8Ki

TaKO8Ki commented on Apr 2, 2021

@TaKO8Ki
Member

@jyn514
I'm sorry. I was busy a while ago, but I have some time on my hands these days, so can I work on this issue some more?

jyn514

jyn514 commented on Apr 2, 2021

@jyn514
Member

Sure thing. If it helps, I think this is the place to look:

fn merge_attrs(

TaKO8Ki

TaKO8Ki commented on Apr 2, 2021

@TaKO8Ki
Member

@jyn514
Thank you! I'm going to take a look.

21 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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

      Participants

      @jplatte@Manishearth@jonas-schievink@GuillaumeGomez@jyn514

      Issue actions

        Documentation of a re-export doesn't appear on level-two re-export · Issue #81893 · rust-lang/rust