-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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.
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-lazy-normalizationArea: Lazy normalization (tracking issue: #60471)Area: Lazy normalization (tracking issue: #60471)A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.