-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Checker:: Execute levenshtein before other context checking #39291
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @arielb1 (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Needs a test at the very least. |
Question: does the other suggestion fire at all anymore? e.g. I would expect rustc to report both hints in case of say:
|
Mmh i don't think it will check for both hints. I will check if i can do it. |
r- from me |
Showing all applicable labels is an alternative too, but I'd like to see first how the result looks visually. |
@Freyskeyd ping. what's the story here? |
hi @mrhota, I didn't work on it for a while (no time for the moment). I can close this PR if it's a problem. |
@bors r=nrc You are more familiar with this code. |
📌 Commit 3d38dbd has been approved by |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit 3d38dbd has been approved by |
🔒 Merge conflict |
a4b67d3
to
eece90f
Compare
☔ The latest upstream changes (presumably #40455) made this pull request unmergeable. Please resolve the merge conflicts. |
46d4f1a
to
dc56bb1
Compare
@Freyskeyd gah sorry for the delay here! It looks like there's some errors on Travis though that would prevent this from landing? |
Is this supposed to be approved? I think @arielb1 meant to r? nrc rather than r=nrc |
r? @nrc |
Yeah, looks like there are some test failures: https://travis-ci.org/rust-lang/rust/jobs/210479172#L4366 Let us know if you need any help @Freyskeyd! |
@carols10cents I will make an update this week. I will let you know if I need some help :) thank's! |
0f3dbd7
to
c487396
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I have your opinion on the reference modification please? cc @carols10cents
@@ -5,6 +5,7 @@ error[E0423]: expected value, found struct `Z` | |||
| ^ | |||
| | | |||
| did you mean `Z { /* fields */ }`? | |||
| did you mean `S`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's unrevelante here. Right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you asking if it's ok that your code change changes these suggestions? I'm not sure :-/ since nrc is on paternity leave right now... @jonathandturner are you the next best person to help out around error message suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I'm asking if it's ok to update that part of suggestion or not. We keep both suggest but is it valid to tell user that, maybe, he misstyped it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok, but Levenshtein suggestions should probably be turned off globally for single-letter identifiers (not necessarily in this PR).
| ^^^ did you mean `Bar`? | ||
| ^^^ | ||
| | | ||
| not found in this scope |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fall-back labels should not be reported if any other labels are reported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @petrochenkov, could you clarify a bit on how @Freyskeyd would fix this so that fall-back labels aren't reported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/librustc_resolve/lib.rs
Outdated
// Try Levenshtein if nothing else worked. | ||
if let Some(candidate) = this.lookup_typo_candidate(path, ns, is_expected) { | ||
err.span_label(ident_span, &format!("did you mean `{}`?", candidate)); | ||
// return err; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also remove this return instead of commenting it out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@petrochenkov Yep, I just let it here to validate behavior with you.
ping @petrochenkov & @Freyskeyd - making sure this PR doesn't disappear. |
@arielb1 I'm working on it^^ |
c487396
to
75b550d
Compare
76e3faa
to
5379203
Compare
src/librustc_resolve/lib.rs
Outdated
// Fallback label. | ||
err.span_label(base_span, &fallback_label); | ||
if err.span.span_labels().is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Freyskeyd
IIRC, span_labels().is_empty()
had quirks and didn't work as expected.
From the tests it looks like it still doesn't work.
You can just set some boolean flag if Levenshtein worked and check it here.
@Freyskeyd |
Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
5379203
to
0d7e6cf
Compare
ping @petrochenkov @carols10cents :) |
@bors r+ |
📌 Commit 0d7e6cf has been approved by |
Checker:: Execute levenshtein before other context checking As explain [here]() i think it's better to check for a miss typing before checking context dependent help. ```rust struct Handle {} struct Something { handle: Handle } fn main() { let handle: Handle = Handle {}; let s: Something = Something { // Checker detect an error and propose a solution with `Handle { /* ... */ }` // but it's a miss typing of `handle` handle: Handle }; } ``` Ping: @nagisa for #39226 Signed-off-by: Freyskeyd <simon.paitrault@gmail.com>
☀️ Test successful - status-appveyor, status-travis |
As explain here i think it's better to check for a miss typing before checking context dependent help.
Ping: @nagisa for #39226
Signed-off-by: Freyskeyd simon.paitrault@gmail.com