Skip to content
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

Trait predicate ambiguities are not always in Self #78111

Merged
merged 2 commits into from
Oct 20, 2020

Conversation

SNCPlay42
Copy link
Contributor

When reporting ambiguities in trait predicates, the compiler incorrectly assumed the ambiguity was always in the type the trait should be implemented on, and never the generic parameters of the trait. This caused silly suggestions for predicates like <KnownType as Trait<_>>, such as giving explicit types to completely unrelated variables that happened to be of type KnownType.

This also reverts #73027, which worked around this issue in some cases and does not appear to be necessary any more.

fixes #77982
fixes #78055

@rust-highfive
Copy link
Collaborator

r? @lcnr

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 19, 2020
@lcnr
Copy link
Contributor

lcnr commented Oct 19, 2020

damn, that's beautiful ❤️ Previously while looking into this with @doctorn I never even thought about this, at least partially because emit_inference_failure_err still took a Ty<'tcx> back then which would have made implementing this PR harder.

Thank you

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 19, 2020

📌 Commit 4cf890cacd538c608e8ac6dcfc7b22a7d5043344 has been approved by lcnr

@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 Oct 19, 2020
@lcnr
Copy link
Contributor

lcnr commented Oct 19, 2020

@bors r- missed something in my review

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 19, 2020
@lcnr
Copy link
Contributor

lcnr commented Oct 19, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Oct 19, 2020

📌 Commit c146e8c has been approved by lcnr

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 19, 2020
@SNCPlay42
Copy link
Contributor Author

SNCPlay42 commented Oct 19, 2020

Searching "type annotations needed" shows a whole bunch of other open issue reports that should be fixed by this (and I can confirm a few locally), non-exhaustive list: #75398, #72616, #71732

I'm not sure if/how many of these are worth adding extra tests for or just marking as closed by this.

@lcnr
Copy link
Contributor

lcnr commented Oct 19, 2020

Hmm, also not sure about that. I think #72616, #71732 are useful as additional tests but we probably can just close #75398 as is

@SNCPlay42
Copy link
Contributor Author

Should we r- and add tests to this PR or clean these up later?

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 20, 2020
Rollup of 10 pull requests

Successful merges:

 - rust-lang#77612 (BTreeMap: test invariants more thoroughly and more readably)
 - rust-lang#77761 (Assert that pthread mutex initialization succeeded)
 - rust-lang#77778 ([x.py setup] Allow setting up git hooks from other worktrees)
 - rust-lang#77838 (const keyword: brief paragraph on 'const fn')
 - rust-lang#77923 ([net] apply clippy lints)
 - rust-lang#77931 (Fix false positive for `unused_parens` lint)
 - rust-lang#77959 (Tweak ui-tests structure)
 - rust-lang#78105 (change name in .mailmap)
 - rust-lang#78111 (Trait predicate ambiguities are not always in `Self`)
 - rust-lang#78121 (Do not ICE on pattern that uses a binding multiple times in generator)

Failed merges:

r? `@ghost`
@bors bors merged commit 3f1c637 into rust-lang:master Oct 20, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 20, 2020
@lcnr
Copy link
Contributor

lcnr commented Oct 20, 2020

will mark these issues as E-needs-test and close #75398

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
5 participants