Closed
Description
This is a repro case for #52462.
Following code:
trait T {
const SIZE: usize;
fn convert(self) -> [u8; T::SIZE];
}
impl T for u64 {
const SIZE: usize = 8;
fn convert(self) -> [u8; u64::SIZE] {
unimplemented!()
}
}
fn main() {}
causes compilation error:
error[E0283]: type annotations required: cannot resolve `_: T`
--> src/main.rs:3:30
|
3 | fn convert(self) -> [u8; T::SIZE];
| ^^^^^^^
|
note: required by `T::SIZE`
--> src/main.rs:2:5
|
2 | const SIZE: usize;
| ^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
However, change from
fn convert(self) -> [u8; u64::SIZE] {
to
fn convert(self) -> [u8; T::SIZE] {
causes following ICE:
error: internal compiler error: librustc/traits/codegen/mod.rs:63: Encountered ambiguity selecting `Binder(<[type error] as T>)` during codegen, presuming due to overflow
thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:578:9
This can be reproduced on stable, beta and nightly. Playground
Meta
rustc 1.30.0-nightly (3edb355 2018-08-03)
binary: rustc
commit-hash: 3edb355
commit-date: 2018-08-03
host: x86_64-unknown-linux-gnu
release: 1.30.0-nightly
LLVM version: 7.0