Explicitly suggest dereferencing when type mismatch differs by reference only #34562
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
Type mismatch error could be more specific and friendlier if it had special handling of case where the compiler found
&type
, but expectedtype
.The current message is correct and (with notes) it's possible to understand it, but "expected
type
, found &-ptr" obscures what type has actually been found (#25426), and makes it sound like a worse mismatch than it really is.Notes for this error make the problem clear, but they're repeating the first part of the message, so it's already using four lines to say one thing. Listing both types requires me to compare them and spot the difference myself.
I hope there are no weird edge cases in this situation, and the compiler could simplify the message by proposing solution outright. Something like:
The text was updated successfully, but these errors were encountered: