Skip to content

ICE w/ default generic type parameter and const parameter #67858

Closed
@petertodd

Description

@petertodd
#![feature(const_generics)]
#![allow(incomplete_features)]

pub trait Trait {
    type Associated;
}

pub struct Foo<T, A = <T as Trait>::Associated, const N: u8>(T, A);

impl<T: Trait, const N: u8> Foo<T, N> {
}

fn main() {
}

results in:

error: internal compiler error: potentially unconstrained type parameters weren't evaluated
  --> potentially-unconstrained.rs:10:1
   |
10 | / impl<T: Trait, const N: u8> Foo<T, N> {
11 | | }
   | |_^

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:345:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.42.0-nightly (c5840f9d2 2020-01-03) running on x86_64-unknown-linux-gnu

Heck, this seems like an unfortunate design-level thing; the ICE aside, is there a way to specify a const generic parameter while using the default?

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.glacierICE tracked in rust-lang/glacier.requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions