Coherence issue when using crate-local traits with type parameters #97811
Labels
A-coherence
Area: Coherence
A-traits
Area: Trait system
A-visibility
Area: Visibility / privacy.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
When using crate-local traits with type parameters, it seems rust incorrectly thinks that downstream crates may implement the trait (which we know to be impossible as the traits are crate-local).
See this playground.
Also captured here for readability:
Expected both impls to compile but only the impl that restricts
C
toLocalTrait
compiles even thoughBarContext<F>
is a supertrait overLocalTrait
which (IIUC) makes theLocalTrait
restriction inC: BarContext<F> + LocalTrait
redundant.Meta
Can observe failure on 2021 edition stable (see rust playground link)
This playground is another example of this but without a
LocalTrait
.Note that using crate-local traits without any type parameters work just fine playground.
The text was updated successfully, but these errors were encountered: