-
Notifications
You must be signed in to change notification settings - Fork 13.3k
impl Trait diagnostic/test cleanups #50943
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0874ba0
Typo caused the wrong "cannot find" error
oli-obk 00842d1
Move a test to ui tests so we can observe the output changes better
oli-obk af75ebd
Improve the diagnostic around impl Trait <-> generic param mismatch
oli-obk 5a7fc9b
Satisfy tidy
oli-obk 849c565
Prevent local paths into libstd from leaking into ui tests
oli-obk 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
File renamed without changes.
Oops, something went wrong.
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.
Use
impl_span
here instead and the output will be correct.This is because
generate_fn_name_span
looks backwards until it findsfn
in the span, instead of checking wether the span starts withfn<WS>
. When usingimpl_m.span
, this starts in thefn...
, so it goes backwards until it finds the previous piece of code that containsfn
, which in this case is the trait's method. Usingimpl_span
will break if any part of the snippet containsfn
(like a method calledmy_fn
).In order to avoid this there are two options: changing
generate_fn_name_span
to peek at the first three chars of the passed span's snippet to see if the first two arefn
and the third is whitespace, and if so assignspan
toprev_span
and use_impl_m_span
here instead, or synthesize a new span derived from_impl_m_span
moving forward long enough to leave thefn<WS>
outside of the new span. Either way, it would have to account for the potential leading whitespace and visibility (pub(crate)
, etc) text.We really need to add spans to all idents, IMO. We keep having to do this kind of brittle span wrangling way too often.