Skip to content

Const generic parameter of type &'static [_] causes ICE #73727

Closed
@yvt

Description

@yvt

Code

#![feature(const_generics)]

fn a<const X: &'static [u32]>() {}

fn main() {
    a::<{&[]}>();
}

Meta

rustc --version --verbose:

rustc 1.46.0-nightly (67100f61e 2020-06-24)
binary: rustc
commit-hash: 67100f61e62a86f2bf9e38552ee138e231eddc74
commit-date: 2020-06-24
host: x86_64-apple-darwin
release: 1.46.0-nightly
LLVM version: 10.0

Error output

warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
 --> a.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default
  = note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information

warning: 1 warning emitted

error: internal compiler error: unexpected consts: a: Const { ty: &[u32], val: Value(ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), alloc2))] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }, b: Const { ty: &'static [u32], val: Value(ByRef { alloc: Allocation { bytes: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [(Size { raw: 0 }, ((), alloc2))] }), init_mask: InitMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) }
  |
  = note: delayed at /rustc/67100f61e62a86f2bf9e38552ee138e231eddc74/src/librustc_session/session.rs:436:27

error: internal compiler error: broken MIR in DefId(0:5 ~ a[317d]::main[0]) (CanonicalUserTypeAnnotation { user_ty: Canonical { max_universe: U0, variables: [], value: TypeOf(DefId(0:3 ~ a[317d]::a[0]), UserSubsts { substs: [Const { ty: &'static [u32], val: Unevaluated(DefId(0:6 ~ a[317d]::main[0]::{{constant}}[0]), [], None) }], user_self_ty: None }) }, span: a.rs:6:5: 6:15 (#0), inferred_ty: fn() {a::<{&[]}>} }): bad user type AscribeUserType(fn() {a::<{&[]}>}, DefId(0:3 ~ a[317d]::a[0]) UserSubsts { substs: [Const { ty: &'static [u32], val: Unevaluated(DefId(0:6 ~ a[317d]::main[0]::{{constant}}[0]), [], None) }], user_self_ty: None }): NoSolution
  |
  = note: delayed at src/librustc_mir/borrow_check/type_check/mod.rs:258:27

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:367: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.46.0-nightly (67100f61e 2020-06-24) running on x86_64-apple-darwin
Backtrace

stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::begin_panic
   8: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   9: core::ptr::drop_in_place
  10: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
  11: core::ptr::drop_in_place
  12: rustc_span::with_source_map
  13: rustc_interface::interface::run_compiler_in_existing_thread_pool
  14: scoped_tls::ScopedKey<T>::set

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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