-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
rust-lang/rust
#119071Description
minimized https://rust.godbolt.org/z/MK6hWKhdb
trait HasProvider<T: ?Sized> {}
trait Provider<M: ?Sized> {
type Interface: ?Sized;
}
struct Service;
struct ServiceImpl;
impl<M: HasProvider<&'static ()> + ?Sized> Provider<M> for ServiceImpl {
type Interface = Service;
}
struct TestModule;
impl HasProvider<&'static ()> for TestModule {}
impl HasProvider<<ServiceImpl as Provider<TestModule>>::Interface> for TestModule {}for whatever reason dyn Repository breaks, () does not.
why this compiles in the old solver:
- before equating impl headers, normalize both impls
Projection(<ServiceImpl as Provider<TestModule>>::Interface)- single candidate with nested goal
TestModule: HasProvider<&'static ()>is simply emitted as a nested goal, successfully normalize toService - equating
impl HasProvider<&'static ()> for TestModule {}withimpl HasProvider<Service> for TestModule {}fails
what's happening in the new solver:
- coherence equates the two impls, resulting in a nested
alias-relate(<ServiceImpl as Provider<TestModule>>::Interface, &'static ()) - uniquification results in
exists<'0> alias-relate(<ServiceImpl as Provider<TestModule>>::Interface, &'0 ()) - normalizes-to candidat with single impl, normalizing to
Servicewith nested goalTestModule: HasProvider<&'static ()>, again, canonicalized to'0 - two candidates:
impl HasProvider<&'static ()> for TestModule {}, YES'0 == 'staticimpl HasProvider<<ServiceImpl as Provider<TestModule>>::Interface> for TestModule {}- unify
<ServiceImpl as Provider<TestModule>>::Interfacewith&'static (), resulting in an inductive cycle
- unify
- AMBIG
- WHY DOES ALIAS-RELATE NOT FAIL?
aliemjay
Metadata
Metadata
Assignees
Labels
No labels