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

Regression in v2: flag constants no longer appear in cargo doc output #320

Closed
nicholasbishop opened this issue Mar 18, 2023 · 3 comments · Fixed by #330
Closed

Regression in v2: flag constants no longer appear in cargo doc output #320

nicholasbishop opened this issue Mar 18, 2023 · 3 comments · Fixed by #330
Labels

Comments

@nicholasbishop
Copy link
Contributor

Steps to reproduce:

cargo new --lib bitflags-missing-docs
cd bitflags-missing-docs
cargo add bitflags

Replace src/lib.rs with:

bitflags::bitflags! {
    pub struct Flags: u32 {
        /// Hello.
        const HELLO = 1;
    }
}

Run cargo doc --open and search for "hello". It doesn't find anything of that name, and if you go to the Flags page it indeed has no documented constants.

image

If you change Cargo.toml to use bitflags = "1" and re-run cargo doc, the constant is there as expected:

image

@nicholasbishop
Copy link
Contributor Author

I think this is due to #282, as demonstrated with this example:

pub struct A;
pub struct B;

impl A {
    pub const VAL: u32 = 0;
}

const _: () = {
    impl B {
        pub const VAL: u32 = 0;
    }
};

pub const B2: u32 = B::VAL;

Running cargo doc on that shows A::VAL but not B::VAL.

@KodrAus
Copy link
Member

KodrAus commented Mar 23, 2023

This issue is fixed upstream, but won't make it to a stable release until April 20th so it might be worth us mitigating it here anyways. It should be fairly straightforward. We can split the impl block that defines those constants from the one that implements other methods and move the constants to outside the const _: () { .. } block.

@nicholasbishop
Copy link
Contributor Author

Thanks for the fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants