Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: redundant_field_names should distinguish between all and some fields matching #3422

Open
taralx opened this issue Nov 10, 2018 · 1 comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy L-style Lint: Belongs in the style lint group

Comments

@taralx
Copy link
Contributor

taralx commented Nov 10, 2018

redundant_field_names fires on any field being a match. This impairs readability in cases like this:

let thingy = Thingy {
   calc: big + calculation,
   redundant: redundant,
   other: stuff.into(),
};

As you can see, if you apply the suggestion, you end up with a weird line that is different from the rest. I suggest that the lint be split such that it distinguishes between "all fields are redundant" and "some fields are redundant".

@flip1995 flip1995 added C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages L-style Lint: Belongs in the style lint group good-first-issue These issues are a good way to get started with Clippy labels Nov 12, 2018
Stebalien referenced this issue in Stebalien/tempfile Jul 1, 2019
Stebalien added a commit to Stebalien/term that referenced this issue Aug 4, 2019
@jmmv
Copy link

jmmv commented Apr 17, 2020

Came here to upvote this FR. But I'd also add that the lint check should also ensure the style is consistent within a given initializer. I.e. if a field has a non-redundant value, then all fields should have explicit values given to them; and if all are redundant, then all should be removed. I think it'd be kind of awkward to have that be a separate lint check than this one, as otherwise the semantics of the two combined might get confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy L-style Lint: Belongs in the style lint group
Projects
None yet
Development

No branches or pull requests

4 participants