Conflict implementation when upstream crate has any impl for any type_alias_impl_trait type
Open
Nobody has claimed this yet.
A-coherence
A-trait-system
C-bug
F-type_alias_impl_trait
T-types
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I tried this code:
/// in crate A
pub trait Test {}
struct A;
impl Test for A {}
pub type OpaqueA = impl Test;
pub fn decide_type() -> OpaqueA {
A
}
pub trait Test2 {}
impl Test2 for OpaqueA {}
/// end of crate A
/// in crate B that depends on crate A
pub struct B;
impl Test2 for B {}
/// end of crate B
I expected to see this happen: compiled successfully
Instead, this happened: failed to compile crateB
error[E0119]: conflicting implementations of trait `crateA::Test2` for type `crateA::OpaqueA`
Meta
rustc --version --verbose:
rustc 1.77.0-nightly (bf8716f1c 2023-12-24)
binary: rustc
commit-hash: bf8716f1cd6416266807706bcae0ecb2e51c9d4a
commit-date: 2023-12-24
host: aarch64-apple-darwin
release: 1.77.0-nightly
LLVM version: 17.0.6
if I merge crate B into crate A, it compiles.
This code works on the previous nightly-2023-06-12 at least.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two-crate example from the issue with the reported rustc 1.77.0 nightly, then compare it with nightly-2023-06-12. Investigate the conflict involving the impl for crateA::OpaqueA and the downstream impl for B; done means the valid two-crate example compiles without the erroneous E0119 conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100