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

Map RPITIT's opaque type bounds back from projections to opaques #114267

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 30, 2023

An RPITIT in a program's AST is eventually translated into both a projection GAT and an opaque. The opaque is used for default trait methods, like:

trait Foo {
  fn bar() -> impl Sized { 0i32 }
}

The item bounds for both the projection and opaque are identical, and both have a projection self ty. This is mostly okay, since we can normalize this projection within the default trait method body to the opaque, but it does two things:

  1. it leads to bugs in places where we don't normalize item bounds, like deduce_future_output_from_obligations
  2. it leads to extra match arms that are both suspicious looking and also easy to miss

This PR maps the opaque type bounds of the RPITIT's opaque back to the opaque's self type to avoid this quirk. Then we can fix the UI test for #108304 (1.) and also remove a bunch of match arms (2.).

Fixes #108304

r? @spastorino

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 30, 2023
@rust-log-analyzer

This comment has been minimized.

@spastorino
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 31, 2023

📌 Commit 6f5c51f has been approved by spastorino

It is now in the queue for this repository.

@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 Jul 31, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 31, 2023
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#114111 (Improve test case for experimental API remove_matches)
 - rust-lang#114169 (refactor builtin unsize handling, extend comments)
 - rust-lang#114182 (clean up after 113312)
 - rust-lang#114193 (Update lexer emoji diagnostics to Unicode 15.0)
 - rust-lang#114200 (Detect trait upcasting through struct tail unsizing in new solver select)
 - rust-lang#114228 (Check lazy type aliases for well-formedness)
 - rust-lang#114267 (Map RPITIT's opaque type bounds back from projections to opaques)
 - rust-lang#114269 (Migrate GUI colors test to original CSS color format)
 - rust-lang#114286 (Add missing feature gate in multiple_supertrait_upcastable doc)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 692d764 into rust-lang:master Jul 31, 2023
11 checks passed
@rustbot rustbot added this to the 1.73.0 milestone Jul 31, 2023
@compiler-errors compiler-errors deleted the rpitit-opaque-bounds branch August 11, 2023 20:18
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix RPIT in default async trait method
5 participants