Suppress missing doc error resulting from a derive macro

I'm trying to be a good citizen and document my crates well. However, using bytemuck::CheckedBitPattern in a derive for my types causes errors:

#![deny(missing_docs)] 

//! This is a test crate
//! This is the doc for it

use bytemuck::CheckedBitPattern;

/// A struct for testing
#[derive(CheckedBitPattern, Copy, Clone)]
#[repr(C)]
struct MyType {
    val : u8,
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error: missing documentation for a struct
 --> src/lib.rs:9:10
  |
9 | #[derive(CheckedBitPattern, Copy, Clone)]
  |          ^^^^^^^^^^^^^^^^^
  |
note: the lint level is defined here
 --> src/lib.rs:1:9
  |
1 | #![deny(missing_docs)] 
  |         ^^^^^^^^^^^^
  = note: this error originates in the derive macro `CheckedBitPattern` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `playground` (lib) due to previous error

Assuming I don't want to edit the upstream crate, nor drop the missing_docs deny, do I have any recourse here?

One option is to place the type in a module and apply #[allow(missing_docs)] to the module. You can the re-export the type so the module doesn't get in the way of imports

#[allow(missing_docs)]
mod inner {
    use bytemuck::CheckedBitPattern;
    /// A struct for testing
    #[derive(CheckedBitPattern, Copy, Clone)]
    #[repr(C)]
    pub struct MyType {
        val: u8,
    }
}

pub use inner::MyType;

Unfortunately just applying the allow to the type doesn't work, and this will prevent the lint from catching if you don't have any docs on MyType.

You could open an issue on the bytemuck repo asking the derive macro to include #[allow(missing_docs)] on the generated struct too.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.