Recommend Option::as_deref
when given Option<&String>
in place of Option<&str>
#89856
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
D-papercut
Diagnostics: An error or lint that needs small tweaks.
P-low
Low priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
&String
can easily be converted to&str
, but we give a somewhat opaque E0308 when faced with the following situation:This results in:
playground
Which is not totally clear to people who do not understand the
Deref
trait and/or do not know that it is implemented for these types.We should suggest that the user use
Option::as_deref
to convert between these types.The text was updated successfully, but these errors were encountered: