-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Add levenshtein distance based suggestions everywhere #30197
Comments
@Manishearth Thanks, I'll try :) |
Go ahead! |
I was surprised that I didn't get a suggestion here fn main() {
"".is_emtpy();
} |
What could one possibly suggest there? :) |
|
Hmm, looks like we currently show suggestions only for the stuff that exist in the source file. |
No, we just don't handle methods. |
Did crate and inline path support ever get added for this? If not, I'd be interested in giving it a shot. |
I don't think so. Go ahead! |
@Manishearth can I pick this up if nobody else is working on it? |
Sure! |
We do not make suggestions for fields behind a reference: struct Ty { field: () }
fn test1(t: Ty) { t.fied }
fn test2(t: &mut Ty) { t.fied }
|
From Issue #38166. Some ideas from: https://gcc.gnu.org/gcc-7/changes.html
In all four cases I'd like the Rust compiler to suggest the closest names (usize/isize, MAX_ITEM, foo_bar, Bar::Second). |
#38154 uses Levenshtein-based suggestions in all path contexts, but there are two more serious problems:
|
resolve: Levenshtein-based suggestions for non-import paths This patch addresses both items from #30197 (comment) and therefore implements the largest part of #30197. r? @jseyfried
Suggestions for last segments of non-import paths are implemented in #38927 Remaining items:
|
Refactor macro resolution errors + add derive macro suggestions Move legacy macro resolution error reporting to `finalize_current_module_macro_resolutions`, and provide suggestions for derive macros. Fixes #39323 cc #30197 r? @jseyfried
Refactor macro resolution errors + add derive macro suggestions Move legacy macro resolution error reporting to `finalize_current_module_macro_resolutions`, and provide suggestions for derive macros. Fixes #39323 cc #30197 r? @jseyfried
Hi! Is anyone working on adding suggestions for method names (re @mitaa's |
Use the syntax::util::lev_distance module to provide suggestions when a named method cannot be found. Part of rust-lang#30197
Add suggestions for misspelled method names Use the syntax::util::lev_distance module to provide suggestions when a named method cannot be found. Part of #30197
If @petrochenkov's list is being kept up-to-date, I think the "method calls" point can be crossed off. |
@laumann |
@petrochenkov Happy to help :-) I considered looking into suggestions for "Lifetime and label names" next - that sounds like it should be more or less straight-forward... |
Another part of rust-lang#30197
…r=petrochenkov Add suggestions for misspelled labels Another part of rust-lang#30197
Triage: do we plan on doing more of this? I'm not sure. |
Currently, we suggest typo fixes in case of function calls, locals, and field accesses. So, both the marked lines below will suggest the correct fix:
However, this is not the case for imports, crates, and inline paths. We should fix this.
This is probably not an easy bug, but should be fun. Basically you need to look for the source of the "could not find X" error, and do something similar to
rust/src/librustc_resolve/lib.rs
Line 3625 in 99925fb
@apasel422 @wafflespeanut want to work on this?
The text was updated successfully, but these errors were encountered: