false negative if_same_then_else / new lint catch wrongly ordered struct init shorthand #6352
Labels
A-lint
Area: New lints
C-bug
Category: Clippy is not doing the correct thing
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
I-false-negative
Issue: The lint should have been triggered on code, but wasn't
Upstream rustc issue: rust-lang/rust#79210
This is definitely also clippy territory!
We have the if_same_than_else lint which probably should catch the upstream example, but I wonder if we could have a lint that catches the field ordering being suspicious.
I tried this code:
The problem is that
S { a, b }
andS { b, a }
is essentially the same, but theif_same_then_else
lint did not see this (probably because of the field ordering).Alternatively, I wonder if it makes sense to have a lint that generally warns we use the shorthand init pattern
where the struct members are not listed in the order that they are defined in the struct definition.
clippy 0.0.212 (fe98231 2020-11-19)
The text was updated successfully, but these errors were encountered: