-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Diagnostics: compiler should hint about .as_ref() when trying to go from &Option<> to Option<&>. #53809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
A-borrow-checker
Area: The borrow checker
A-diagnostics
Area: Messages for errors, warnings, and lints
Comments
Similar issue to #43861, which was fixed with a targeted hack in #51100. The first two cases could probably be handled by extending that code, the last two are lifetime errors so they would need to touch a different part of the compiler. For future reference, the four cases produce the following output:
|
Current output for 3 and 4:
Note the suggestions are accurate and fix the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-borrow-checker
Area: The borrow checker
A-diagnostics
Area: Messages for errors, warnings, and lints
Compiler message should hint
Option::as_ref
, to shift user attention from object inside Option to the Option itself.The text was updated successfully, but these errors were encountered: