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 {}
I am trying to compile the following code
The compilation is failing with:
However, if I relax the
FullBlock
trait requirements it compiles fineMeta
rustc --version --verbose
: