RS.CLIPPY.REDUNDANT_FIELD_NAMES
Checks for fields in struct literals where shorthands could be used
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: redundant_field_names. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Checks for fields in struct literals where shorthands could be used.
Why is this bad?
If the field and variable names are the same, the field name is redundant.
Example
let bar: u8 = 123;
struct Foo {
bar: u8,
}
let foo = Foo { bar: bar };
the last line can be simplified to
let foo = Foo { bar };
Configuration
-
msrv: The minimum rust version that the project supports. Defaults to therust-versionfield inCargo.toml(default:
current version)