New lint: Unnecessarily complex types #4844
Labels
A-lint
Area: New lints
E-hard
Call for participation: This a hard problem and requires more experience or effort to work on
L-unnecessary
Lint: Warn about unnecessary code
It would be nice to lint on return types that are more complex than necessary. Take for example the following function (playground):
The
Result
here is not necessary, because the function always returns anOk
variant.I would also like to see a similar lint for
fn f() -> Option<T>
wheref
always returnsSome
.Note this is not the same as https://rust-lang.github.io/rust-clippy/current/index.html#type_complexity, which is about return types that are hard to read, not return types that are unnecessary.
Possible output for the lint (just making this up here):
The text was updated successfully, but these errors were encountered: