Closed
Description
Hello,
I have hit this strange error after updating the nightly(and beta) compiler. I tried the code below, this is a minimized version from a larger code base. Here is it on playground.
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>>
}
fn main() {}
I am getting this error and I don't know how usize
is involved here.
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`
After bisecting for a while, I discovered the error appears starting with this version of nightly:
$ rustc --version --verbose
rustc 1.30.0-nightly (f2302daef 2018-09-12)
binary: rustc
commit-hash: f2302daef3608c09e2b50193a64611b18ced86f3
commit-date: 2018-09-12
host: x86_64-unknown-linux-gnu
release: 1.30.0-nightly
LLVM version: 8.0
The build from the day before doesn't show this error (and stable is also fine):
$ rustc --version --verbose
rustc 1.30.0-nightly (2f1547c0a 2018-09-11)
binary: rustc
commit-hash: 2f1547c0aa5957b42cc768c00119c6eb7b4262d3
commit-date: 2018-09-11
host: x86_64-unknown-linux-gnu
release: 1.30.0-nightly
LLVM version: 8.0