Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beta regression error "trait ... is not implemented for usize" #56020

Closed
ketotek opened this issue Nov 17, 2018 · 5 comments
Closed

Beta regression error "trait ... is not implemented for usize" #56020

ketotek opened this issue Nov 17, 2018 · 5 comments
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ketotek
Copy link

ketotek commented Nov 17, 2018

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
@csmoe csmoe added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. regression-from-stable-to-beta Performance or correctness regression from stable to beta. and removed regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Nov 17, 2018
@pietroalbini pietroalbini added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Nov 19, 2018
@pietroalbini pietroalbini changed the title Nightly regression error "trait ... is not implemented for usize" Beta regression error "trait ... is not implemented for usize" Nov 19, 2018
@pietroalbini
Copy link
Member

cc @rust-lang/compiler

@Mark-Simulacrum Mark-Simulacrum added this to the Rust 2018 Release milestone Nov 20, 2018
@nikomatsakis
Copy link
Contributor

This has a fix

@nikomatsakis
Copy link
Contributor

#56003

@nikomatsakis
Copy link
Contributor

Also included already in #56102 for backport

@alexcrichton
Copy link
Member

Ok great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants