Suggest swapping LHS and RHS for PartialEq
#130495
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
For more information about this error, try
rustc --explain E0308
.Rationale and extra context
Because
PartialEq<Rhs>
is asymmetric,t == s
ands == t
are semantically different ifs
andt
are different types. Because most people view==
as being a symmetric operation, this could lead to confusion ifT
implementsPartialEq<S>
butS
does not implementPartialEq<T>
. Thus, providing a hint that swapping the LHS and RHS of the equality operator could elucidate why the error is occurring.Other cases
No response
Rust Version
rustc 1.81.0 (eeb90cd 2024-09-04)
binary: rustc
commit-hash: eeb90cd
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7
Anything else?
No response
The text was updated successfully, but these errors were encountered: