Skip to content

Creating a safe_suggestion attribute for coerce suggestions #37474

Closed
@GuillaumeGomez

Description

@GuillaumeGomez

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions