Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICE when using associated constant as fixed-length array size #26402

Closed
ProtectedMode opened this issue Jun 18, 2015 · 3 comments
Closed

ICE when using associated constant as fixed-length array size #26402

ProtectedMode opened this issue Jun 18, 2015 · 3 comments
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@ProtectedMode
Copy link

While trying to create a generic vector type, I stumbled upon the following ICE:

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
thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefTyParam(TypeSpace, 0, DefId { krate: 0, node: 13 }, "G"(66)), last_private: LastMod(AllPublic), depth: 1 }', ../src/librustc/middle/def.rs:81

This error occurs with the following code, which is a pretty minimal test case:

#![feature(associated_consts)]

trait GenericVector {
    const size: usize;
}

struct Vector<G: GenericVector> {
    data: [f32; G::size],
}

struct D3;

impl GenericVector for D3 {
    const size: usize = 3;
}

fn main() {
    let vector = Vector::<D3> {
        data: [0.0, 3],
    };
}

Backtrace:

   1:     0x7f9bcc7063d3 - sys::backtrace::write::h42760ef5ab82bcd2irs
   2:     0x7f9bcc70e521 - panicking::on_panic::h12f68dc29fcc5657Tax
   3:     0x7f9bcc6cd28a - rt::unwind::begin_unwind_inner::h68e746642e433893DQw
   4:     0x7f9bcc6cdec7 - rt::unwind::begin_unwind_fmt::h22d77de4e1204a17JPw
   5:     0x7f9bca663e0b - middle::const_eval::eval_const_expr_with_substs::h6757944525066075748
   6:     0x7f9bca611e0b - middle::const_eval::eval_const_expr_partial::hc18213693094f10f8Lk
   7:     0x7f9bcbeca428 - astconv::ast_ty_to_ty::hc4d699607bfa4965Qfw
   8:     0x7f9bcbf4848e - iter::Map<I, F>.Iterator::next::h9665268986370662205
   9:     0x7f9bcbf3a928 - collect::convert_struct::h6bc1f37bd9a66db7pky
  10:     0x7f9bcbf2b595 - collect::convert_item::h18e8c114ea4837bbrZx
  11:     0x7f9bcbf26c46 - collect::collect_item_types::h4321500fa840372f35w
  12:     0x7f9bcbf7a3b6 - check_crate::h15b94c5d979eb877VgD
  13:     0x7f9bccc6dcb9 - driver::phase_3_run_analysis_passes::h535099e77e0d0b0aHGa
  14:     0x7f9bccc4f55a - driver::compile_input::hf94b88e60b92b1d3Sba
  15:     0x7f9bccd0b2e7 - run_compiler::hd38788069be51651F7b
  16:     0x7f9bccd088d6 - boxed::F.FnBox<A>::call_box::h10971823990562187917
  17:     0x7f9bccd080d9 - rt::unwind::try::try_fn::h13260011850501376318
  18:     0x7f9bcc78aea8 - rust_try_inner
  19:     0x7f9bcc78ae95 - rust_try
  20:     0x7f9bcc6f9147 - rt::unwind::try::inner_try::hb6dce8ad1d668192wMw
  21:     0x7f9bccd082f9 - boxed::F.FnBox<A>::call_box::h7963608429107561708
  22:     0x7f9bcc70d151 - sys::thread::Thread::new::thread_start::h82e421ca205cff91sWv
  23:     0x7f9bc62706a9 - start_thread
  24:     0x7f9bcc358eec - clone
  25:                0x0 - <unknown>

Version:

rustc 1.2.0-nightly (20d23d8e5 2015-06-18)
binary: rustc
commit-hash: 20d23d8e57c0313c811135535d6872463cc6525d
commit-date: 2015-06-18
host: x86_64-unknown-linux-gnu
release: 1.2.0-nightly

I've searched for similar issues but all issues I found were either different or closed.

@arielb1
Copy link
Contributor

arielb1 commented Jun 18, 2015

cc @quantheory

@quantheory
Copy link
Contributor

I think this is the same as #25145. We can't resolve associated constants in collect right now, which means that in many type definitions, they don't work.

Note that this code should be rejected anyway until we have an RFC for generic constants, e.g. from rust-lang/rfcs#1062.

@alexcrichton
Copy link
Member

Closing in favor of #25145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants