Open
Description
With this source
use core::marker::PhantomData;
pub trait Wrap<T> {
type Wrapper;
}
fn fail<
T,
C: Trait<<WrapMarker as Wrap<T>>::Wrapper>
+ Wrap<<C as Trait<<WrapMarker as Wrap<T>>::Wrapper>>::Assoc>,
>() {
}
fn succeed<
T,
C: Trait<PhantomData<T>> + Wrap<<C as Trait<<WrapMarker as Wrap<T>>::Wrapper>>::Assoc>,
>() {
}
pub trait Trait<P> {
type Assoc;
}
pub struct WrapMarker;
impl<T> Wrap<T> for WrapMarker {
type Wrapper = PhantomData<T>;
}
I expect both fail
and succeed
to compile. Instead, fail
fails to compile with "E0277: the trait bound C: Trait<std::marker::PhantomData<T>>
is not satisfied". rustc
is clearly able to unambiguously resolve the type here, not only just in theory as associated types are singly defined for a given parametrization, but in practice as it is able to clearly specify the constraint to be added, indicating that <C as Trait<<WrapMarker as Wrap<T>>::Wrapper
is already uniquely resolved.