Skip to content

Type mismatch method suggestion doesn't work for as_deref #80508

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

Closed
jplatte opened this issue Dec 30, 2020 · 2 comments
Closed

Type mismatch method suggestion doesn't work for as_deref #80508

jplatte opened this issue Dec 30, 2020 · 2 comments
Labels
A-result-option Area: Result and Option combinators A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jplatte
Copy link
Contributor

jplatte commented Dec 30, 2020

It would be really nice if the mismatched type diagnostic would work for as_deref. Currently, trying to use Option<Vec<String>> where Option<&[String]> is expected doesn't give a method call suggestion the way one gets a suggestion to borrow when trying to use Vec<String> where &[String] is expected.

   = note: expected enum `std::option::Option<&[std::string::String]>`
              found enum `std::option::Option<Vec<std::string::String>>`

^ no suggestion

@jplatte
Copy link
Contributor Author

jplatte commented Dec 30, 2020

Hm actually it also doesn't work for as_ref or cloned / copied. Are there just special cases for some &str / String and Vec / slice method but no general mechanism?

@camelid camelid added A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` A-result-option Area: Result and Option combinators C-enhancement Category: An issue proposing an enhancement or a PR with one. labels Dec 30, 2020
@JohnTitor JohnTitor added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 5, 2021
@jplatte
Copy link
Contributor Author

jplatte commented Jun 8, 2023

Fixed by #111659, I think.

@jplatte jplatte closed this as completed Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-result-option Area: Result and Option combinators A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants