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

inductive cycles as ambig causes unintended breakage #114

Open
lcnr opened this issue May 22, 2024 · 2 comments
Open

inductive cycles as ambig causes unintended breakage #114

lcnr opened this issue May 22, 2024 · 2 comments

Comments

@lcnr
Copy link
Contributor

lcnr commented May 22, 2024

trait Trait {
    type Item;
}

fn foo<A: Trait, B: Trait>()
where
    A::Item: Trait<Item = u32>,
    B::Item: Trait<Item = i32>,
{}

this should compile but fails with

error[E0283]: type annotations needed: cannot satisfy `<A as Trait>::Item: Trait`
 --> <source>:7:14
  |
7 |     A::Item: Trait<Item = u32>,
  |              ^^^^^^^^^^^^^^^^^
  |

The underlying issue is trying to prove <A as Trait>::Item: Trait normalizes the self type:

  • normalizes-to(<A as Trait>::Item)
    • candidate A::Item: Trait<Item = u32>
      • alias-relate(A::Item, A)
        • normalizes-to(<A as Trait>::Item) inductive cycle
    • candidate B::Item: Trait<Item = i32>
      • alias-relate(B::Item, A)
        • normalizes-to(<B as Trait>::Item)
          • candidate A::Item: Trait<Item = u32>
            • alias-relate(A::Item, B)
              • normalizes-to(<A as Trait>::Item) inductive cycle
          • candidate B::Item: Trait<Item = i32>
            • alias-relate(B::Item, B)
              • normalizes-to(<B as Trait>::Item) inductive cycle
@lcnr
Copy link
Contributor Author

lcnr commented May 22, 2024

original test by @aliemjay ❤️

pub trait ParallelIterator {
    type Item;
}

impl<T> ParallelIterator for T {
    type Item = u32;
}

trait Trait {}

impl<A, B> Trait for (A, B) where
    //~^ type annotations needed: cannot satisfy `<<A as ParallelIterator>::Item as ParallelIterator>::Item == u32`
    A: ParallelIterator,
    A::Item: ParallelIterator<Item = u32>,
    B: ParallelIterator,
    B::Item: ParallelIterator<Item = u32>,
{}


fn main() {}

@lcnr
Copy link
Contributor Author

lcnr commented May 22, 2024

this is the underlying reason for #111, closing that issue

trait Trait<'a> {
    type Assoc;
}

fn foo<'a, T: Trait<'a>>()
where
    T::Assoc: Trait<'a>,
{}

this may also be the root cause of #89

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

No branches or pull requests

1 participant