Skip to content

ICE with an associated constant as the length of a fixed-size array type of a static variable #25145

@ghost

Description

I tried this code:

#![feature(associated_consts)]

struct S;

impl S {
    const N: usize = 3;
}

static STUFF: [u8; S::N] = [0; S::N];

// NOTE: This works OK:
// static STUFF: [u8; 3] = [0; S::N];

fn main() {
    // NOTE: This works OK:
    // let stuff: [u8; S::N] = [0; S::N];
}

I get the error:

thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTy(DefId { krate: 0, node: 4 }, false), last_private: LastMod(AllPublic), depth: 1 }', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/librustc/middle/def.rs:81

Meta

rustc --version --verbose:
rustc 1.1.0-nightly (7bd7163 2015-05-06) (built 2015-05-05)
binary: rustc
commit-hash: 7bd7163
commit-date: 2015-05-06
build-date: 2015-05-05
host: x86_64-apple-darwin
release: 1.1.0-nightly

Stack backtrace:

   1:        0x10eb86f5f - sys::backtrace::write::hc8a4ac867687625dies
   2:        0x10eb8fa50 - panicking::on_panic::h8a20ee230368976dxuw
   3:        0x10eb49b45 - rt::unwind::begin_unwind_inner::hdec022e876757f01gcw
   4:        0x10eb4a96c - rt::unwind::begin_unwind_fmt::h6ffe61c334a81630mbw
   5:        0x10bd00e38 - middle::const_eval::eval_const_expr_partial::h814207524cef7390Tii
   6:        0x10b9c0aed - astconv::ast_ty_to_ty::h9119a591013371dfrSv
   7:        0x10ba41933 - collect::type_scheme_of_item::h3901b884cf3c707cdny
   8:        0x10ba39a2c - collect::convert_typed_item::h12a84069945ba57eQry
   9:        0x10ba211ad - collect::convert_item::hcb1eaa0733f02657eBx
  10:        0x10ba67b56 - check_crate::closure.38613
  11:        0x10ba65ada - check_crate::h71ec2befa9b49c1f5CC
  12:        0x10b2cff27 - driver::phase_3_run_analysis_passes::hcfdd4de2213fe030tGa
  13:        0x10b2b1c2c - driver::compile_input::h93cb3a50ed1b3f97Qba
  14:        0x10b370c93 - run_compiler::h7ca7d41460963b3165b
  15:        0x10b36e3fa - boxed::F.FnBox<A>::call_box::h5883147459539851824
  16:        0x10b36d957 - rt::unwind::try::try_fn::h498179752253104642
  17:        0x10ec12028 - rust_try_inner
  18:        0x10ec12015 - rust_try
  19:        0x10b36dc2d - boxed::F.FnBox<A>::call_box::h5554344682679983399
  20:        0x10eb8e44d - sys::thread::Thread::new::thread_start::h71342e3350e45779fxv
  21:     0x7fff921d0267 - _pthread_body
  22:     0x7fff921d01e4 - _pthread_start

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions