RS.CLIPPY.DEFAULT_CONSTRUCTED_UNIT_STRUCTS

Unit structs can be constructed without calling `default`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: default_constructed_unit_structs. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for construction on unit struct using default.

Why is this bad?

This adds code complexity and an unnecessary function call.

Example

#[derive(Default)]
struct S<T> {
    _marker: PhantomData<T>
}

let _: S<i32> = S {
    _marker: PhantomData::default()
};

Use instead:

struct S<T> {
    _marker: PhantomData<T>
}

let _: S<i32> = S {
    _marker: PhantomData
};