-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)C-bugCategory: This is a bug.Category: This is a bug.F-const_generics`#![feature(const_generics)]``#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.