RS.CLIPPY.DERIVABLE_IMPLS
Manual implementation of the `Default` trait which is equal to a derive
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: derivable_impls. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Detects manual std::default::Default implementations that are identical to a derived implementation.
Why is this bad?
It is less concise.
Example
struct Foo {
bar: bool
}
impl Default for Foo {
fn default() -> Self {
Self {
bar: false
}
}
}
Use instead:
#[derive(Default)]
struct Foo {
bar: bool
}
Known problems
Derive macros sometimes use incorrect bounds
in generic types and the user defined impl may be more generalized or
specialized than what derive will produce. This lint can't detect the manual impl
has exactly equal bounds, and therefore this lint is disabled for types with
generic parameters.
Configuration
-
msrv: The minimum rust version that the project supports. Defaults to therust-versionfield inCargo.toml(default:
current version)