Skip to content

Custom (synonym) suggestions for nonexistent methods #51398

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

Open
varkor opened this issue Jun 6, 2018 · 2 comments
Open

Custom (synonym) suggestions for nonexistent methods #51398

varkor opened this issue Jun 6, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints 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

@varkor
Copy link
Member

varkor commented Jun 6, 2018

Currently if the user types a method that does not exist, a suggestion may be provided if what was typed is reasonably close to an existing method.

let set = ::std::collections::HashSet::new();
set.insrt(0u8); // = help: did you mean `insert`?

However, this only catches typos — completely different names aren't considered "close". I think it'd be helpful, especially for people coming from other languages (or switching between them frequently) to be able to specify custom suggestions for potential alternate names, so that something like the following works:

let set = ::std::collections::HashSet::new();
set.add(0u8); // = help: did you mean `insert`?
set.push(0u8); // = help: did you mean `insert`?
// etc.
@varkor varkor changed the title Custom suggestions for nonexistent methods Custom (synonym) suggestions for nonexistent methods Jun 6, 2018
@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Jun 6, 2018
@varkor
Copy link
Member Author

varkor commented Nov 30, 2018

We could potentially use #[doc(alias)] for this. (Similar suggestion here: https://internals.rust-lang.org/t/pre-rfc-filter-map-for-option/8932/8.)

@steveklabnik
Copy link
Member

Triage: i don't believe anything has been done with this.

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-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

4 participants