Skip to content

Do not show negative polarity trait implementations in diagnostic messages for similar implementations #79606

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 3 commits into from
Dec 2, 2020
Merged

Conversation

ThePuzzlemaker
Copy link
Contributor

This fixes #79458.

Previously, this code:

#[derive(Clone)]
struct Foo<'a, T> {
    x: &'a mut T,
}

would have suggested that <&mut T as Clone> was an implementation that was found. This is due to the fact that the standard library now has impl<'_, T> !Clone for &'_ mut T, and explicit negative polarity implementations were not filtered out in diagnostic output when suggesting similar implementations.

This PR fixes this issue by filtering out negative polarity trait implementations in find_similar_impl_candidates within rustc_trait_selection::traits::error_reporting::InferCtxtPrivExt<'tcx>. It also adds a UI regression test for this issue and fixes UI tests that had incorrectly been modified to expect the invalid output.

r? @scottmcm

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 1, 2020
@ThePuzzlemaker
Copy link
Contributor Author

ThePuzzlemaker commented Dec 1, 2020

Failures were due to GHA, it says there's a check error on .github#L1

@scottmcm
Copy link
Member

scottmcm commented Dec 2, 2020

Thanks for the PR! I re-kicked the actions and it looks like they worked. Great to get all that other test output cleaned up too.

@bors r+

@bors
Copy link
Collaborator

bors commented Dec 2, 2020

📌 Commit b287806 has been approved by scottmcm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 2, 2020
@bors
Copy link
Collaborator

bors commented Dec 2, 2020

⌛ Testing commit b287806 with merge d37afad...

@bors
Copy link
Collaborator

bors commented Dec 2, 2020

☀️ Test successful - checks-actions
Approved by: scottmcm
Pushing d37afad to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 2, 2020
@bors bors merged commit d37afad into rust-lang:master Dec 2, 2020
@rustbot rustbot added this to the 1.50.0 milestone Dec 2, 2020
@ThePuzzlemaker ThePuzzlemaker deleted the issue-79458-fix branch December 2, 2020 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Negative trait impls show as "found implementations" in error messages
5 participants