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 on const generic array lenght when using opperator #66752

Closed
aDotInTheVoid opened this issue Nov 25, 2019 · 1 comment
Closed

ICE on const generic array lenght when using opperator #66752

aDotInTheVoid opened this issue Nov 25, 2019 · 1 comment

Comments

@aDotInTheVoid
Copy link
Member

Code:

#![feature(const_generics)]

struct Foo<const X: usize> {
    bar: [i32; X + 1],
}

Expected: Compiles Sucessfuly
Actual: ICE

rustc 1.41.0-nightly (412f43ac5 2019-11-24)
binary: rustc
commit-hash: 412f43ac5b4ae8c3599e71c6972112e9be4758fa
commit-date: 2019-11-24
host: x86_64-apple-darwin
release: 1.41.0-nightly
LLVM version: 9.0

Backtrace:

 $ RUST_BACKTRACE=1 cargo build
   Compiling const_vector v0.1.0 (/Users/nixon/dev/rs/const-vector)
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> src/lib.rs:1:12
  |
1 | #![feature(const_generics)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default

error: internal compiler error: src/librustc/ty/subst.rs:650: const parameter `X/#0` (Const { ty: usize, val: Param(X/#0) }/0) out of range when substituting substs=[]

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:851:9
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::span_bug
   9: rustc_errors::Handler::span_bug
  10: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc::ty::context::tls::with_opt::{{closure}}
  12: rustc::ty::context::tls::with_opt
  13: rustc::util::bug::opt_span_bug_fmt
  14: rustc::util::bug::span_bug_fmt
  15: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_const
  16: rustc::traits::codegen::<impl rustc::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
  17: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_operand
  18: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  19: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  20: rustc_mir::const_eval::const_eval_raw_provider
  21: rustc::ty::query::__query_compute::const_eval_raw
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  23: rustc_mir::const_eval::const_eval_provider
  24: rustc::ty::query::__query_compute::const_eval
  25: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  26: rustc_mir::const_eval::const_eval_provider
  27: rustc::ty::query::__query_compute::const_eval
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: rustc::ty::sty::Const::eval
  32: <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty
  33: rustc::traits::project::normalize
  34: rustc_typeck::check::FnCtxt::normalize_associated_types_in
  35: <core::iter::adapters::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  36: rustc::ty::context::GlobalCtxt::enter_local
  37: rustc_typeck::check::wfcheck::check_item_well_formed
  38: rustc::ty::query::__query_compute::check_item_well_formed
  39: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_item_well_formed>::compute
  40: rustc::dep_graph::graph::DepGraph::with_task_impl
  41: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  43: __rust_maybe_catch_panic
  44: rustc_data_structures::sync::par_for_each_in
  45: __rust_maybe_catch_panic
  46: rustc::hir::Crate::par_visit_all_item_likes
  47: rustc::util::common::time
  48: rustc_typeck::check_crate
  49: rustc_interface::passes::analysis
  50: rustc::ty::query::__query_compute::analysis
  51: rustc::dep_graph::graph::DepGraph::with_task_impl
  52: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  53: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  54: rustc_interface::passes::create_global_ctxt::{{closure}}
  55: rustc_interface::passes::BoxedGlobalCtxt::enter
  56: rustc_interface::interface::run_compiler_in_existing_thread_pool
  57: std::thread::local::LocalKey<T>::with
  58: scoped_tls::ScopedKey<T>::set
  59: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.41.0-nightly (412f43ac5 2019-11-24) running on x86_64-apple-darwin

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [const_eval_raw] const-evaluating `Foo::bar::{{constant}}#0`
#1 [const_eval] const-evaluating + checking `Foo::bar::{{constant}}#0`
#2 [const_eval] const-evaluating + checking `Foo::bar::{{constant}}#0`
#3 [check_item_well_formed] processing `Foo`
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `const_vector`.

To learn more, run the command again with --verbose.
@jonas-schievink
Copy link
Contributor

Duplicate of #60619

@jonas-schievink jonas-schievink marked this as a duplicate of #60619 Nov 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants