-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Point only to the identifiers in the typo suggestions of shadowed names instead of the entire struct #103560
Merged
Merged
Point only to the identifiers in the typo suggestions of shadowed names instead of the entire struct #103560
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
be61f02
Add Span in TypoSuggestion and TypoCandidate
zbyrn 0b936d2
Add check to only output 'you might have meant' when the candidate na…
zbyrn 775328c
Modify check to output 'you might have meant' for indirect reference
zbyrn 0eaf6d5
Modify ui tests to reflect the change
zbyrn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 7 additions & 9 deletions
16
src/test/ui/resolve/point-at-type-parameter-shadowing-another-type.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do you have an example where removing the
is_local
andis_in_same_file
filters give the wrong suggestions?TBH, I'm not fond of the filename-based logic. We should either formulate the logic in terms of modules, or drop
is_in_same_file
.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.
When we shadow something in another crate, the suggestion would potentially point at a distant file in which the shadowed name is defined. For example, compiling
will give the following error message:
Note that the suggestion here points at something in the implementation of
std
. If this is okay, we could just remove both checks and simplify the code. The suggestion given here is not wrong technically, but I think it is not very helpful either.I'm not a fan of the filename hack as well, and it was certainly a last resort as I'm still familiarizing myself with the code base. Could we achieve the same effect by comparing the
ctx
's of the two spans?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.
On a second thought, we could actually use the span of the resolver's module span (
self.r.graph_root.span
) to test whether the underlined definition is in the current module. Pushing a change and amending this PR shortlyThere 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.
graph_root.span
is the span of thelib.rs
file. Using it to decide is definitely wrong.The former version of this PR is the better middle ground.
Could you remove the last commit, and I'll approve the PR. Thanks
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.
Ah, my bad for misunderstanding what
graph_root
means! A reversion has been pushed.Thanks for your comments and your approval!