Closed as not planned
Closed as not planned
Description
Summary
Clippy silences struct_field_names
for public structs. This is good and makes sense; the field is part of the public API and renaming it would be a breaking change. However, it still emits the lint for structs with derive(Deserialize)
. I think these should also be silenced, because Serialize
and Deserialize
are "super public" - not just available to other crates, but to other programs as well.
Lint Name
struct_field_names
Reproducer
I tried this code:
#![warn(clippy::pedantic)]
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct Resource {
pub(crate) id: String,
pub(crate) name: String,
pub(crate) resource_group: String,
}
I saw this happen:
warning: field name starts with the struct's name
--> src/lib.rs:9:5
|
9 | pub(crate) resource_group: String,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#struct_field_names
note: the lint level is defined here
--> src/lib.rs:1:9
|
1 | #![warn(clippy::pedantic)]
| ^^^^^^^^^^^^^^^^
= note: `#[warn(clippy::struct_field_names)]` implied by `#[warn(clippy::pedantic)]`
I expected to see this happen: No lint is emitted.
As an aside, the lint stops firing if i remove id
or name
, which seems quite odd.
Version
clippy 0.1.75 (82e1608d 2023-12-21)
rustc 1.75.0 (82e1608df 2023-12-21)
Additional Labels
No response