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

existential predicate dedup + inference vars is incomplete #154

Closed
lcnr opened this issue Jan 29, 2025 · 2 comments
Closed

existential predicate dedup + inference vars is incomplete #154

lcnr opened this issue Jan 29, 2025 · 2 comments
Assignees

Comments

@lcnr
Copy link
Contributor

lcnr commented Jan 29, 2025

trait Super {
    type Assoc;
}

trait Trait<T>: Super<Assoc = u32> {}

trait Eq<T: ?Sized> {}
impl<T: ?Sized> Eq<T> for T {}

trait Constrain<T: ?Sized, U: ?Sized> {}
impl<T: ?Sized, U: ?Sized> Constrain<T, U> for ()
where
    dyn Trait<U, Assoc = U>: Eq<T>,
    dyn Trait<u32, Assoc = u32>: Eq<T>,

{}

fn foo<T: Constrain<U, V>, U: ?Sized, V: ?Sized>() {}
fn main() {
    foo::<(), _, _>();
} 

results in the following error with both the new and old solver

error[E0277]: the trait bound `(dyn Trait<u32> + 'static): Eq<(dyn Trait<_, Assoc = _> + 'static)>` is not satisfied
  --> <source>:20:11
   |
20 |     foo::<(), _, _>();
   |           ^^ the trait `Eq<(dyn Trait<_, Assoc = _> + 'static)>` is not implemented for `(dyn Trait<u32> + 'static)`

however, the underlying issue results in an ICE in tests/ui/issues/issue-59326.rs while equating canonical var values in a proof tree visitor.

@lcnr
Copy link
Contributor Author

lcnr commented Jan 29, 2025

ICE with both old and new solver:

trait Super {
    type Assoc;
}

trait Trait<T>: Super<Assoc = u32> {}

trait Eq<T: ?Sized> {}
impl<T: ?Sized> Eq<T> for T {}
trait Constrain<T: ?Sized, U: ?Sized> {}
impl<U: ?Sized> Constrain<dyn Trait<U, Assoc = U>, U> for ()
where
    u32: Eq<U>,
{}

fn foo<T: Constrain<U, V>, U: ?Sized, V: ?Sized>() {}
fn main() {
    foo::<(), _, _>();
}

@lcnr
Copy link
Contributor Author

lcnr commented Jan 29, 2025

will be fixed by rust-lang/rust#136458

@lcnr lcnr moved this to in progress in -Znext-solver=globally Jan 29, 2025
@lcnr lcnr moved this from in progress to done in -Znext-solver=globally Feb 22, 2025
@lcnr lcnr closed this as completed Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants