Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

cargo doc does not show impls inside of a const item #109320

Closed
nicholasbishop opened this issue Mar 18, 2023 · 2 comments
Closed

cargo doc does not show impls inside of a const item #109320

nicholasbishop opened this issue Mar 18, 2023 · 2 comments
Labels
C-bug Category: This is a bug.

Comments

@nicholasbishop
Copy link
Contributor

nicholasbishop commented Mar 18, 2023

I noticed in the new bitflags v2 release that the flags are no longer showing up cargo doc output. I filed a bug in the bitflags project for that, but it seems like potentially incorrect behavior on the part of cargo doc as well. Example code:

pub struct S;

trait T {}

const _: () = {
    impl S {
        // Does not show in docs.
        pub const VAL: u32 = 0;

        // Does not show in docs.
        const fn f() {}
    }

    // Does not show in docs.
    impl T for S {}
};

// Demonstrate that S::VAL and S::f are accessible.
pub const C1: u32 = S::VAL;
pub const C2: () = S::f();
// Demonstrate that S impls T
pub fn x() {
    let _t: &dyn T = &S;
}

Since S::VAL and S::f are visible outside the empty const _: () item, I would expect them to show up in the cargo doc output, but they don't. Similar for the impl T for S.

This is not a regression as far as I can tell from checking a few versions of Rust at random.

Meta

rustc --version --verbose:

rustc 1.68.0 (2c8cc3432 2023-03-06)
binary: rustc
commit-hash: 2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74
commit-date: 2023-03-06
host: x86_64-unknown-linux-gnu
release: 1.68.0
LLVM version: 15.0.6
@nicholasbishop nicholasbishop added the C-bug Category: This is a bug. label Mar 18, 2023
@GuillaumeGomez
Copy link
Member

It was fixed in #107000:

Screenshot from 2023-03-19 14-14-44

Since S::VAL and S::f are visible outside the empty const _: () item, I would expect them to show up in the cargo doc output, but they don't. Similar for the impl T for S.

S::f is private, same as T, so unless you use --document-private-items, they won't appear in the documentation since they're only public inside the current crate.

@nicholasbishop
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants