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

Generate Normalize clauses for dyn and opaque types #780

Merged
merged 1 commit into from
Jun 13, 2023

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Oct 21, 2022

When a trait Trait has a transitive supertrait defined like trait SuperTrait: AnotherTrait<Assoc = Ty>, we've been generating impl AnotherTrait for dyn Trait and opaque type T: Trait but without accounting for the associated type bound. This patch adds Normalize clauses that correspond to such bounds.

For example, given the following definition

trait SuperTrait where WC {
   type Assoc where AssocWC;
}
trait Trait: SuperTrait<Assoc = Ty> {}

we generate the following clauses

// for dyn Trait
Implemented(dyn Trait: SuperTrait) :- WC
Normalize(<dyn Trait as SuperTrait>::Assoc -> Ty) :- WC, AssocWC // this patch adds this
// for placeholder !T for opaque type T: Trait
Implemented(!T: SuperTrait) :- WC
Normalize(<!T as SuperTrait>::Assoc -> Ty) :- WC, AssocWC // this patch adds this

I think this doesn't contradict #203 as "we may legitimately assume that all things talking directly about ?Self are true", but I'm not really sure if this is the right direction. One caveat is that this patch exacerbates "wastefulness" as in this comment as it adds the Normalize clauses even when we're trying to prove other kinds of goals.

Fixes #777

@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 13, 2023

📌 Commit 1346728 has been approved by jackh726

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 13, 2023

⌛ Testing commit 1346728 with merge 1635ed5...

@bors
Copy link
Contributor

bors commented Jun 13, 2023

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing 1635ed5 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to deduce projection types of dyn types from supertrait bounds
3 participants