Skip to content

ICE with const_generic + associated type + double return statement #64519

Closed
@simon-auch

Description

@simon-auch

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

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.F-const_generics`#![feature(const_generics)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions