Hello,
I've been trying to figure out the source of a strange error coming from a larger code base and managed to minimize it. The code is:
trait MyIterator {
type Item;
}
trait ObjectTrait {
fn size(&self) -> u32;
}
trait ObjectCollectionTrait<'a> {
type ItemType: 'a + ObjectTrait;
type Iter: MyIterator<Item = &'a Self::ItemType>;
}
impl ObjectTrait for u32 {
fn size(&self) -> u32 {
0
}
}
struct ObjectCollection<'a> {
collection: &'a ObjectCollectionTrait<'a, ItemType = u32, Iter = MyIterator<Item = &'a u32>>
}
The error:
error[E0277]: the trait bound `usize: ObjectCollectionTrait<'a>` is not satisfied --> src/main.rs:21:1 | 21 | / struct ObjectCollection<'a> { 22 | | collection: &'a ObjectCollectionTrait<'a, ItemType = u32, Iter = MyIterator<Item = &'a u32>>
23 | | }
| |_^ the trait `ObjectCollectionTrait<'a>` is not implemented for `usize`
error[E0277]: the trait bound `usize: ObjectCollectionTrait<'a>` is not satisfied
--> src/main.rs:25:10
|
25 | impl<'a> ObjectCollection<'a> {
| ^^^^^^^^^^^^^^^^^^^^ the trait `ObjectCollectionTrait<'a>` is not implemented for `usize`
What is interesting is that I bisected this and it compiles fine with nightly-2018-09-12-x86_64-unknown-linux-gnu, but not the build from the following day.
Any ideas what is the bug in the code and what changed in the compiler ? I don't understand where the usize
in the error message comes from.