Regression in v2: flag constants no longer appear in `cargo doc` output · Issue #320 · bitflags/bitflags · GitHub
Skip to content

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

Closed

Description

@nicholasbishop

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

Activity

  1. nicholasbishop commented on Mar 18, 2023

    @nicholasbishop
    ContributorAuthor

    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.

  2. KodrAus commented on Mar 23, 2023

    @KodrAus
    Member

    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.

  3. nicholasbishop commented on Apr 3, 2023

    @nicholasbishop
    ContributorAuthor

    Thanks for the fix :)

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions