Skip to content

Creating a safe_suggestion attribute for coerce suggestions #37474

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
GuillaumeGomez opened this issue Oct 29, 2016 · 3 comments
Closed

Creating a safe_suggestion attribute for coerce suggestions #37474

GuillaumeGomez opened this issue Oct 29, 2016 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@GuillaumeGomez
Copy link
Member

In #37388, coerce suggestions have been added. However, the system isn't very clever and will propose everything matching, wether or not it corresponds to the actual user's needs. For example:

let x: u32 = String::new();

In this case, we get len() and capacity() methods suggested. But in the example, we could think that the user wanted a conversion, and if this is the case, the suggestions are completely wrong.

In order to improve this, @jonathandturner proposed a safe_suggestion attribute. I agree with this proposition but a few details still need to be "fixed":

  • Should we loop through "safe" methods only?
  • How should we consider that a "safe" method matches the current user's need?
  • If the safe_suggestion attribute is adopted, should we have to add it over every methods that would be considered as a safe suggestion?

I might have forget other potential issues so don't hesitate to add them if this is the case.

@GuillaumeGomez
Copy link
Member Author

cc @eddyb

@Mark-Simulacrum
Copy link
Member

As far as I know there hasn't been any progress on this.

@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 22, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 26, 2017
@crlf0710 crlf0710 added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 11, 2020
@estebank
Copy link
Contributor

estebank commented Jun 8, 2022

Closing in favor of #59450, which has the approach that I think is more likely to work. We no longer suggest arbitrary method based on their return types.

@estebank estebank closed this as completed Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-feature-request Category: A feature request, i.e: not implemented / a PR. 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

4 participants