Advertise matches!
as an alternative to PartialEq on E0369
#140287
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Code
Current output
Desired output
Rationale and extra context
People coming from other programming languages might not be aware that by-value comparison (requiring
PartialEq
) and pattern-matching aren't the same thing. Clippy warns-by-default specifically onOption<T> == None
(looking at you, Python!).IMHO the help on E0369 should advertise both solutions here; it's an anti-pattern to teach people that by-value comparison is required when they are actually doing structural comparison.
Other cases
Rust Version
Anything else?
playground
The text was updated successfully, but these errors were encountered: