Idea: suggest coercing to &T
from &mut T
if it satisfies type check
#109352
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Finally getting around to filing this issue at @estebank's encouragement in this (rather embarrassing) Reddit thread. CC @WalterSmuts and @pali6.
Code
I've tried to capture things in this Playground link; to summarize:
Current output
Desired output
Rationale and extra context
It seems like this should generally be a valid suggestion, and we have to create a diagnostic for this; current error output doesn't help the user to discover the "right" solution at all.
Other cases
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: