Diagnostics: suggest using from_str
when calling parse
on a type that implements FromStr
#77843
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
A-trait-system
Area: Trait system
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
D-terse
Diagnostics: An error or lint that doesn't give enough information about the problem at hand.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Problem
I find myself confusing the
parse
andfrom_str
methods quite often. Take for example:parse
doesn't exist onJdbcString
;from_str
does. So the way to fix it would be to write:Solution
It'd be great if the diagnostic could detect if
parse
was called on a type that implementsFromStr
and suggest to usefrom_str
instead:The text was updated successfully, but these errors were encountered: