-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code:
fn main() {
let a = &1;
let b = 1;
if a == b {
println!("equal");
} else {
println!("not equal");
}
}
Error:
error[E0277]: the trait bound `&{integer}: std::cmp::PartialEq<{integer}>` is not satisfied
--> <anon>:4:8
|
4 | if a == b {
| ^^^^^^ the trait `std::cmp::PartialEq<{integer}>` is not implemented for `&{integer}`
|
= help: the following implementations were found:
= help: <&'a A as std::cmp::PartialEq<&'b B>>
= help: <&'a mut A as std::cmp::PartialEq<&'b mut B>>
= help: <&'a A as std::cmp::PartialEq<&'b mut B>>
= help: <&'a mut A as std::cmp::PartialEq<&'b B>>
= help: and 586 others
error: aborting due to previous error
This error message is somewhat intimidating. Assuming the user knows to add a *
or &
, which side do they add it to? It might be not too difficult with this example to deduce that, but when dealing with double nested references and other shenanigans, it'd be a lot easier if we just suggested where to put the *
and &
.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.