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

Check for opaque types behind projections #99857

Closed
wants to merge 1 commit into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 28, 2022

Fixes #99840

I still dislike how fragile this is, but integrating into the regular orphan check doesn't really make sense either, it's not about orphan checking at all.

r? @lcnr

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 28, 2022
@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 28, 2022
@lcnr
Copy link
Contributor

lcnr commented Jul 28, 2022

that approach doesn't work i think, consider

#![feature(type_alias_impl_trait)]
trait Foo {
    type Assoc;
}

impl Foo for i32 {
    type Assoc = u32;
}
type ImplTrait = impl Sized;
fn constrain() -> ImplTrait {
    1u64
}
impl Foo for i64 {
    type Assoc = ImplTrait;
}

trait Bar<T> {}

impl<T: Foo> Bar<<T as Foo>::Assoc> for T {}

i don't think we can avoid opaque types during coherence. I think we should allow them but treat them as opaque so that they block impls for any other type which i added to #99840 (comment) as an edit 😁

@lcnr
Copy link
Contributor

lcnr commented Jul 28, 2022

for #76202 we have to not return a SimplifiedType for opaque types in impls so that they're added to blanket_impls.

not sure about #86411 but it seems fixable and #84660 is caused by opaque types not being considered "opaque enough" i think

@lqd
Copy link
Member

lqd commented Jul 29, 2022

if this approach is not going to work or land soon, should we revert #99383 in the meantime ?

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 29, 2022

if this approach is not going to work or land soon, should we revert #99383 in the meantime ?

No, this is all behind feature gates, so we're not going to affect stable code.

@oli-obk oli-obk closed this Aug 24, 2022
@oli-obk oli-obk deleted the impl_trait_for_tait branch August 24, 2022 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TAIT: it's possible to impl a trait for a tait by using projections
5 participants