Closed
Description
I tried this code:
#![feature(const_generics)]
#![feature(const_generic_impls_guard)]
use core::array::LengthAtMost32;
struct Foo<const D: usize> {
state: Option<[u8;D]>,
}
impl<const D: usize> Iterator for Foo<{D}> where
[u8;D]: LengthAtMost32,
{
type Item = [u8; D];
fn next(&mut self) -> Option<Self::Item> {
return Some(self.state.unwrap().clone());
return Some(self.state.unwrap().clone());
}
}
I expected to see this happen:
It should build.
Instead, this happened:
rustc crashed with:
error: internal compiler error: src/librustc/infer/unify_key.rs:143: equating two const variables, both of which have known values
Possible workaround:
replace Self::Item
with [u8;D]
.
Meta
playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=849c7ac992950ce15a2fcf075fd61828
rustc version: 1.39.0-nightly 2019-09-15 96d07e0