idanarye / rust-typed-builder

Compile-time type-checked builder derive
https://crates.io/crates/typed-builder
Apache License 2.0
904 stars 52 forks source link

Suppress `clippy::exhaustive_enums` on generated enums #112

Closed xFrednet closed 11 months ago

xFrednet commented 11 months ago

Clippy struggles a bit with code generated by derive macros. It currently detects some enum generated by #[derive(TypedBuilder)], if clippy::exhaustive_enums is enabled.

Reproducer:

#![warn(clippy::exhaustive_enums)]

use typed_builder::TypedBuilder;

#[derive(TypedBuilder)]
pub struct Bar {
    pub a: i32,
    pub b: String,
}

Now run cargo clippy

Fix

The easiest fix would probably be to generate a #[allow(clippy::exhaustive_enums)] above the enum. That would simply suppress the lint for this specific enum. For my use case, it's totally fine, that the enum is non_exhaustive.