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

Spelling suggestions should consider trailing exclamation points #5780

Closed
bstrie opened this issue Apr 8, 2013 · 7 comments · Fixed by #29968
Closed

Spelling suggestions should consider trailing exclamation points #5780

bstrie opened this issue Apr 8, 2013 · 7 comments · Fixed by #29968
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@bstrie
Copy link
Contributor

bstrie commented Apr 8, 2013

< sawrubh> suppose I wrote assert instead of assert!, I get this message
           : unresolved name: `assert`. Did you mean: `result`? what's
           the thing which generates the last suggestion
< sawrubh> I think that suggesting that I'm missing an ! would be more
           helpful, so just wondering who decides and how it decides what
           to suggest as the solution

As an aside, assert -> result is still a hilariously large edit distance.

@sawrubh
Copy link
Contributor

sawrubh commented Apr 8, 2013

The search should be first if the spelling mistake is a part of the macros or some other keyword in the language and try and match it with that. If that fails only then suggest other local variables as the correction.

@thestinger
Copy link
Contributor

@sawrubh: I think edit distance takes care of this fine. I don't think ert should autocorrect to assert! instead of a local variable called cert. Heuristics like that would just hurt.

@emberian
Copy link
Member

emberian commented Jul 7, 2013

I think it should suggest a macro if the identifier is identical, but it shouldn't suggest it otherwise

@huonw
Copy link
Member

huonw commented Aug 11, 2014

Still an issue:

fn main() {
    let result = 1i;
    assert(true);
}
<anon>:3:5: 3:11 error: unresolved name `assert`. Did you mean `result`?
<anon>:3     assert(true);
             ^~~~~~

@frewsxcv
Copy link
Member

frewsxcv commented Feb 2, 2015

Still an issue (same input/output as @huonw's comment above)

@Manishearth
Copy link
Member

This can be done by holding on to the SyntaxEnv (or just a vec of strings built from the syntaxenv) after expand_crate and passing it down to librustc_resolve through the driver. Not exactly a clean solution, but not too bad either.

@Manishearth
Copy link
Member

Opened #29968

Manishearth added a commit to Manishearth/rust that referenced this issue Nov 22, 2015
flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 14, 2020
flip1995 added a commit to flip1995/rust that referenced this issue Jul 14, 2020
Fix out of bounds access by checking length equality BEFORE accessing by index.

Fixes rust-lang#5780

changelog: fix out of bounds access in unnested_or_patterns lint.

Edit: I did not bother reducing a testcase from `librustc_typeck` crate but I can confirm that with the change the crash no longer occurs.
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
Projects
None yet
8 participants