-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
fix: dedup static_candidates
before report
#111872
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
trait Cat { | ||
fn nya() {} | ||
} | ||
|
||
fn uwu<T: Cat>(c: T) { | ||
c.nya(); | ||
//~^ ERROR no method named `nya` found for type parameter `T` in the current scope | ||
//~| Suggestion T::nya() | ||
} | ||
|
||
fn main() {} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
error[E0599]: no method named `nya` found for type parameter `T` in the current scope | ||
--> $DIR/issue-103646.rs:6:7 | ||
| | ||
LL | fn uwu<T: Cat>(c: T) { | ||
| - method `nya` not found for this type parameter | ||
LL | c.nya(); | ||
| --^^^-- | ||
| | | | ||
| | this is an associated function, not a method | ||
| help: use associated function syntax instead: `T::nya()` | ||
| | ||
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter | ||
note: the candidate is defined in the trait `Cat` | ||
--> $DIR/issue-103646.rs:2:5 | ||
| | ||
LL | fn nya() {} | ||
| ^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0599`. |
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.
Could you add a comment why we cannot remove the duplicated call to
record_static_candidate
?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.
inherent
andextension
may append the same item tostatic_candidates
.For example:
Both
<T as Cat>
(inherent) and<_ as Cat>
(extension) had been tried.And another:
<_ as Cat>
(extension) should be tried.Therefore, we can't remove duplicated call of
record_static_candidate
.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.
The comment you added says that in order to improve the diagnostic, we record both inherent and extension cases. But this PR does the opposite: we deduplicate to improve the diagnostic.
You don't need to link to the PR. The 2 lines-long explanation is enough.
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.
I have two questions:
record_static_candidate
? Also, is it intended behavior that the unexpected diagnostic of Unhelpful help when calling associated trait function as method #103646 was caused by invoking record_static_candidate
for the same item in both assemble_extension_candidates_for_trait
and assemble_inherent_impl_probe
?static_candidates.dedup()
the right approach here? If this statement has too broad impact, can we change the condition to !self.has_applicable_self(&item) && !self.static_candidates.contains(&item)
in extension_candidates?