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 auto trait clauses for opaque type goals #468

Merged
merged 2 commits into from
May 26, 2020

Conversation

detrumi
Copy link
Member

@detrumi detrumi commented May 22, 2020

When you have opaque type Foo: Trait = Bar,
solving the goal Foo: Send
will generate Foo: Send :- Bar: Send

@detrumi detrumi force-pushed the opaque-auto-traits branch from d362b5e to 8a3e89f Compare May 22, 2020 09:17
chalk-solve/src/clauses.rs Outdated Show resolved Hide resolved
opaque_id
);

let opaque_ty_datum = &builder.db.opaque_ty_data(opaque_id);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder that we should factor the "hidden type" out from this struct and make it something that we lazilly request

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would that work, actually? A method on the database to request it, or something similar?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just a separate method on the db that only gets invoked when auto trait impls are actually required (that's important) would be fine, I think

chalk-solve/src/clauses.rs Outdated Show resolved Hide resolved
@@ -161,7 +224,12 @@ fn program_clauses_that_could_match<I: Interner>(

if trait_datum.is_non_enumerable_trait() || trait_datum.is_auto_trait() {
let self_ty = trait_ref.self_type_parameter(interner);
if self_ty.bound_var(interner).is_some()

if let TyData::Alias(AliasTy::Opaque(opaque_ty)) = self_ty.data(interner) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably wants to be the placeholder, and not the alias type, but we can leave it as "future work" for now

@nikomatsakis nikomatsakis merged commit e5aaf83 into rust-lang:master May 26, 2020
@detrumi detrumi deleted the opaque-auto-traits branch January 31, 2021 08:12
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.

3 participants