Skip to content
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

Tighten up the edit-distance suggestions on resolve #2281

Closed
brson opened this issue Apr 25, 2012 · 5 comments
Closed

Tighten up the edit-distance suggestions on resolve #2281

brson opened this issue Apr 25, 2012 · 5 comments
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Apr 25, 2012

We currently have an edit-distance "did you mean $somethingelse" check in resolve if there's no match for an identifier. This does not limit the distance and is somewhat limited in where it looks. Fix these issues.

@brson
Copy link
Contributor Author

brson commented Sep 25, 2012

Some useful discussion about this: Mozilla-Student-Projects/Projects-Tracker#32

bors added a commit that referenced this issue Feb 27, 2013
Address #2281


```
-> % cat foo.rs
fn foo() -> int {
    let bar = 10;

    bad
}
```

```
-> % rustc foo.rs
foo.rs:4:4: 4:7 error: unresolved name: `bad`. Did you mean: `bar`?
foo.rs:4     bad
             ^~~
error: aborting due to previous error
```
@lifthrasiir
Copy link
Contributor

The current suggestion is limited to the local scope, and doesn't have an edit distance limit. Thus the following code:

fn main() {
    let sep = ~" ";
    str::conect(~[~"foo", ~"bar"], sep);
}

...results in the strange (if not funny) message:

t.rs:3:10: 3:21 error: unresolved name: `str::conect`. Did you mean: `sep`?
t.rs:3              str::conect(~[~"foo", ~"bar"], sep);
                    ^~~~~~~~~~~

@graydon
Copy link
Contributor

graydon commented Mar 12, 2013

updated description to current state of affairs.

@nikomatsakis
Copy link
Contributor

The current algorithm yields some truly surprising results. For example, I had some code where I typed supertraits instead of supertrait_refs, and it suggested f instead....this could of course be a legitimate result of the distance algorithm, I suppose.

bors added a commit that referenced this issue Mar 28, 2013
Impose a limit so that the typo suggester only shows reasonable
suggestions (i.e. don't suggest `args` when the error is `foobar`).

A tiny bit of progress on #2281.
@pcwalton
Copy link
Contributor

Closing. I haven't seen any really strange suggestions (and in fact the suggestions were helpful).

bors added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2022
Rustup

Fix our stacktrace after rust-lang#98549. Now we can control whether `caller_location` should be pruned!
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Create a RFC for feature gate for APIs included in the Kani library.

Tracking issue: rust-lang#2279

Co-authored-by: Adrian Palacios <73246657+adpaco-aws@users.noreply.github.com>
jieyouxu pushed a commit to jieyouxu/rust that referenced this issue Mar 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

5 participants