-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Open
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.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.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.
Description
I am trying to compile the following code
struct MyBlock;
trait Block {
type Header;
}
impl Block for MyBlock {
type Header = ();
}
trait Header {}
impl Header for () {}
trait FullBlock: Block<Header: Header> {}
impl<T> FullBlock for T where T: Block<Header: Header> {}
trait Primitives {
type Block;
}
trait FullPrimitives: Primitives<Block: FullBlock<Header = Self::Header>> {
type Header;
}
impl<T> FullPrimitives for T where T: Primitives<Block: FullBlock> {
type Header = <<T as Primitives>::Block as Block>::Header;
}
fn test<P: FullPrimitives<Block = MyBlock>>() {}The compilation is failing with:
error[E0283]: type annotations needed: cannot satisfy `MyBlock: FullBlock`
--> src/main.rs:30:12
|
30 | fn test<P: FullPrimitives<Block = MyBlock>>() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: cannot satisfy `MyBlock: FullBlock`
note: required by a bound in `FullPrimitives`
--> src/main.rs:22:41
|
22 | trait FullPrimitives: Primitives<Block: FullBlock<Header = Self::Header>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `FullPrimitives`
For more information about this error, try `rustc --explain E0283`.
error: could not compile `my_project` (bin "my") due to 1 previous error
However, if I relax the FullBlock trait requirements it compiles fine
-trait FullBlock: Block<Header: Header> {}
-impl<T> FullBlock for T where T: Block<Header: Header> {}
+trait FullBlock: Block {}
+impl<T> FullBlock for T where T: Block {}Meta
rustc --version --verbose:
rustc 1.84.0-nightly (c1db4dc24 2024-10-25)
binary: rustc
commit-hash: c1db4dc24267a707409c9bf2e67cf3c7323975c8
commit-date: 2024-10-25
host: aarch64-apple-darwin
release: 1.84.0-nightly
LLVM version: 19.1.1
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.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.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.Fixed by the next-generation trait solver, `-Znext-solver`.