No documentation for the FooBits public type generated by derive(CheckedBitPattern)
ia0 opened this issue · 1 comments
ia0 commented
Using derive(CheckedBitPattern)
unconditionally triggers the missing_docs
lint. This seems to be because the generated FooBits
type is public and without documentation. For example, if a crate using bytemuck
would have the following src/lib.rs
:
//! foo.
#![warn(missing_docs)]
/// Foo.
#[derive(Copy, Clone, bytemuck::CheckedBitPattern)]
#[repr(C)]
pub struct Foo {
/// x.
x: u8,
}
There would be some FooBits
public type generated as follow (according to cargo expand
):
#[repr(C)]
pub struct FooBits {
x: <u8 as ::bytemuck::CheckedBitPattern>::Bits,
}
This type does not have a documentation although Foo
has one.
There are at least 3 options to solve this issue:
- Reuse the documentation of
Foo
forFooBits
. - Reuse the documentation of
Foo
forFooBits
but slightly modify it to say that all bit patterns are valid. - Generate a custom documentation for
FooBits
stating that it's a version ofFoo
with only valid bit patterns.
Lokathor commented
I'd love a PR for this.
I think option 3 is best, just add a docs line that the type is generated and doesn't need to be used by humans.