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

rustc panic: Type parameter R/#1 (R/1) out of range when substituting... #58987

Closed
Vociferix opened this issue Mar 7, 2019 · 12 comments
Closed
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Vociferix
Copy link

Please see this repo for more details. Commit 628894b, which is the only commit at this time, as I created the repo specifically for this issue. It's an in progress library with a lot of early experimentation in it.

Below is the compiler and build information. Based on the information, it appears the problem has to do
with rust's in-progress const semantics, although I might not know what I'm talking about. I just know
that my use of const and generics in this library is fairly atypical (or at least I believe it to be),
so it makes sense to me that the problem lies there.

I apologize for the state of this code base. It has no comments, no tests, and is full of experimentation
code to see what will compile and what won't. I did at least clean up all the warnings before posting
this, to make life a bit easier. It is a one-man hobby project, and I am still relatively new to rust. A
lot of the code here is my personal translation of C++ meta programming over to rust.

A note to keep in mind: Everything compiled until I added the threading code for AsyncIO in
src/detail/io.rs, which I find interesting since it appears to be complaining about something that
previously compiled with no problem, and is unrelated to the threading code.

Also note that if the compiler did not panic, there is a good chance there is something actually wrong
with the code that would fail to compile, which would be something in src/detail/io.rs.

$ rustc --version
rustc 1.33.0 (2aa4c46cf 2019-02-28)
$ rustup show
Default host: x86_64-unknown-linux-gnu

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
beta-x86_64-unknown-linux-gnu
nightly-x86_64-unknown-linux-gnu

active toolchain
----------------

stable-x86_64-unknown-linux-gnu (default)
rustc 1.33.0 (2aa4c46cf 2019-02-28)

$ RUST_BACKTRACE=FULL cargo build --verbose
   Compiling io-cache v0.1.0 (/home/jack/devel/io-cache)
     Running `rustc --edition=2018 --crate-name io_cache src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=531453a790193d18 -C extra-filename=-531453a790193d18 --out-dir /home/jack/devel/io-cache/target/debug/deps -C incremental=/home/jack/devel/io-cache/target/debug/incremental -L dependency=/home/jack/devel/io-cache/target/debug/deps`
error: internal compiler error: src/librustc/ty/subst.rs:480: Type parameter `R/#1` (R/1) out of range when substituting (root type=Some(detail::set::NWaySet<L, R, Block, Blocks>)) substs=[detail::set::NWaySet<L, R, Block, Blocks>]

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:526:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  15: <smallvec::SmallVec<A> as core::iter::traits::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  16: rustc::ty::fold::TypeFoldable::fold_with
  17: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  18: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  19: <smallvec::SmallVec<A> as core::iter::traits::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  20: rustc::ty::fold::TypeFoldable::fold_with
  21: rustc::traits::codegen::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'tcx>>::subst_and_normalize_erasing_regions
  22: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::resolve
  23: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::run
  24: rustc_mir::const_eval::eval_body_using_ecx
  25: rustc_mir::const_eval::const_eval_raw_provider
  26: rustc::ty::query::__query_compute::const_eval_raw
  27: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval_raw<'tcx>>::compute
  28: rustc::dep_graph::graph::DepGraph::with_task_impl
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  30: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::const_eval_raw
  31: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::const_value_to_op
  32: rustc_mir::const_eval::lazy_const_to_op
  33: rustc_mir::transform::const_prop::ConstPropagator::eval_constant
  34: <rustc_mir::transform::const_prop::ConstPropagator<'b, 'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_statement
  35: <rustc_mir::transform::const_prop::ConstProp as rustc_mir::transform::MirPass>::run_pass
  36: rustc_mir::transform::run_passes::{{closure}}
  37: rustc_mir::transform::run_passes
  38: rustc_mir::transform::optimized_mir
  39: rustc::ty::query::__query_compute::optimized_mir
  40: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::optimized_mir<'tcx>>::compute
  41: rustc::dep_graph::graph::DepGraph::with_task_impl
  42: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  43: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_optimized_mir
  44: rustc_metadata::encoder::<impl rustc_metadata::isolated_encoder::IsolatedEncoder<'a, 'b, 'tcx>>::encode_info_for_impl_item
  45: rustc::dep_graph::graph::DepGraph::with_ignore
  46: rustc_metadata::encoder::<impl rustc_metadata::index_builder::IndexBuilder<'a, 'b, 'tcx>>::encode_addl_info_for_item
  47: rustc::hir::Crate::visit_all_item_likes
  48: rustc_metadata::encoder::encode_metadata
  49: rustc_metadata::cstore_impl::<impl rustc::middle::cstore::CrateStore for rustc_metadata::cstore::CStore>::encode_metadata
  50: rustc::ty::context::TyCtxt::encode_metadata
  51: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::ExtraBackendMethods>::write_metadata
  52: rustc::util::common::time
  53: rustc_codegen_ssa::base::codegen_crate
  54: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
  55: rustc::util::common::time
  56: rustc_driver::driver::phase_4_codegen
  57: rustc_driver::driver::compile_input::{{closure}}
  58: <std::thread::local::LocalKey<T>>::with
  59: rustc::ty::context::TyCtxt::create_and_enter
  60: rustc_driver::driver::compile_input
  61: rustc_driver::run_compiler_with_pool
  62: <scoped_tls::ScopedKey<T>>::set
  63: rustc_driver::run_compiler
  64: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
#0 [const_eval_raw] const-evaluating `<detail::set::NWaySet<L, R, Block, Blocks> as detail::set::Set>::STATIC_META_MEM`
   --> src/detail/set.rs:206:32
    |
206 |       const MEM_PER_SET: usize = (Block::LEN * Blocks::LEN)
    |  ________________________________^
207 | |         + NWaySet::<L, R, Block, Blocks>::STATIC_META_MEM
    | |_________________________________________________________^
#1 [optimized_mir] processing `<detail::set::NWaySets<L, R, Block, Blocks, S>>::MEM_PER_SET`
end of query stack
error: aborting due to previous error


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.33.0 (2aa4c46cf 2019-02-28) running on x86_64-unknown-linux-gnu

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

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

error: Could not compile `io-cache`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name io_cache src/lib.rs --color always --crate-type lib --emit=dep-info,link -C debuginfo=2 -C metadata=531453a790193d18 -C extra-filename=-531453a790193d18 --out-dir /home/jack/devel/io-cache/target/debug/deps -C incremental=/home/jack/devel/io-cache/target/debug/incremental -L dependency=/home/jack/devel/io-cache/target/debug/deps` (exit code: 101)
@oli-obk oli-obk added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) labels Mar 7, 2019
@Centril Centril added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 7, 2019
@jonas-schievink jonas-schievink added the C-bug Category: This is a bug. label Apr 14, 2019
@faern
Copy link
Contributor

faern commented Apr 16, 2019

I ran into a very similar ICE on the following code:

use std::mem;

fn foo<T: ?Sized>(t: T) {
    let _ = [(); 0 - !(mem::size_of::<&T>() == mem::size_of::<[usize; 2]>()) as usize];
}

I'm not 100% sure they originate from the same bug. But I would assume so given the similarities in backtraces. Here is my stacktrace from trying to build on rustc 1.35.0-nightly (2975a3c4b 2019-04-15):

error: internal compiler error: src/librustc/ty/subst.rs:546: Type parameter `T/#0` (T/0) out of range when substituting (root type=Some(fn() -> usize {std::mem::size_of::<&T>})) substs=[]

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:570:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:59
             at src/libstd/panicking.rs:197
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:211
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:478
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty
  15: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
  16: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty
  17: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  18: rustc::ty::fold::TypeFoldable::fold_with
  19: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with
  20: <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty
  21: rustc_mir::interpret::eval_context::InterpretCx<M>::monomorphize
  22: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpretCx<M>>::eval_const_to_op
  23: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpretCx<M>>::run
  24: rustc_mir::const_eval::eval_body_using_ecx
  25: rustc_mir::const_eval::const_eval_raw_provider
  26: rustc::ty::query::__query_compute::const_eval_raw
  27: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute
  28: rustc::dep_graph::graph::DepGraph::with_task_impl
  29: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  30: rustc_mir::const_eval::const_eval_provider
  31: rustc::ty::query::__query_compute::const_eval
  32: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute
  33: rustc::dep_graph::graph::DepGraph::with_task_impl
  34: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  35: rustc_typeck::check::FnCtxt::check_expr_kind
  36: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  37: rustc_typeck::check::FnCtxt::check_decl_initializer
  38: rustc_typeck::check::FnCtxt::check_decl_local
  39: rustc_typeck::check::FnCtxt::check_stmt
  40: rustc_typeck::check::FnCtxt::check_block_with_expected
  41: rustc_typeck::check::FnCtxt::check_expr_kind
  42: rustc_typeck::check::FnCtxt::check_expr_with_expectation_and_needs
  43: rustc_typeck::check::FnCtxt::check_return_expr
  44: rustc_typeck::check::check_fn
  45: rustc::ty::context::GlobalCtxt::enter_local
  46: rustc_typeck::check::typeck_tables_of
  47: rustc::ty::query::__query_compute::typeck_tables_of
  48: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
  50: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  51: rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners
  52: rustc_typeck::check::typeck_item_bodies
  53: rustc::ty::query::__query_compute::typeck_item_bodies
  54: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_item_bodies>::compute
  55: rustc::dep_graph::graph::DepGraph::with_task_impl
  56: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  57: rustc::util::common::time
  58: rustc_typeck::check_crate
  59: rustc_interface::passes::analysis
  60: rustc::ty::query::__query_compute::analysis
  61: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::analysis>::compute
  62: rustc::dep_graph::graph::DepGraph::with_task_impl
  63: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  64: rustc::ty::context::tls::enter_global
  65: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  66: rustc_interface::passes::create_global_ctxt::{{closure}}
  67: rustc_interface::passes::BoxedGlobalCtxt::enter
  68: rustc_interface::interface::run_compiler_in_existing_thread_pool
  69: std::thread::local::LocalKey<T>::with
  70: scoped_tls::ScopedKey<T>::set
  71: syntax::with_globals
query stack during panic:
#0 [const_eval_raw] const-evaluating `foo::{{constant}}#0`
#1 [const_eval] const-evaluating + checking `foo::{{constant}}#0`
#2 [typeck_tables_of] processing `foo`
#3 [typeck_item_bodies] type-checking all item bodies
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


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.35.0-nightly (2975a3c4b 2019-04-15) running on x86_64-unknown-linux-gnu

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

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

@pearfalse
Copy link

Here's another repro case I came across:

struct A<T> {
    field: [u8; f::<&T>()],
}
fn f<T>() -> usize { 0 }

The function call used as the array size doesn't have to be an intrinsic, or even a const fn. It just has to be specialized with a type reference, and return usize (possibly to pass through earlier checks).

Full stack trace (rustc 1.34.0 stable, MacOS 10.12.6):

error: internal compiler error: src/librustc/ty/subst.rs:480: Type parameter `T/#0` (T/0) out of range when substituting (root type=Some(fn() -> usize {f::<&T>})) substs=[]

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:558:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
   1: std::sys_common::backtrace::_print
   2: std::panicking::default_hook::{{closure}}
   3: std::panicking::default_hook
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  15: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  16: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  17: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  18: rustc::ty::fold::TypeFoldable::fold_with
  19: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  20: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  21: <rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::monomorphize
  22: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::const_to_op
  23: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::eval_lazy_const_to_op
  24: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::EvalContext<'a, 'mir, 'tcx, M>>::run
  25: rustc_mir::const_eval::eval_body_using_ecx
  26: rustc_mir::const_eval::const_eval_raw_provider
  27: rustc::ty::query::__query_compute::const_eval_raw
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval_raw<'tcx>>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  31: rustc_mir::const_eval::const_eval_provider
  32: rustc::ty::query::__query_compute::const_eval
  33: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::const_eval<'tcx>>::compute
  34: rustc::dep_graph::graph::DepGraph::with_task_impl
  35: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  36: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_const
  37: rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable<'tcx> for &'tcx rustc::ty::TyS<'tcx>>::super_fold_with
  38: <rustc::traits::project::AssociatedTypeNormalizer<'a, 'b, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  39: rustc::traits::project::normalize
  40: rustc::infer::InferCtxt::partially_normalize_associated_types_in
  41: <core::iter::adapters::Map<I, F> as core::iter::traits::iterator::Iterator>::fold
  42: rustc::ty::context::GlobalCtxt::enter_local
  43: rustc_typeck::check::wfcheck::check_item_well_formed
  44: rustc::ty::query::__query_compute::check_item_well_formed
  45: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::check_item_well_formed<'tcx>>::compute
  46: rustc::dep_graph::graph::DepGraph::with_task_impl
  47: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  48: rustc::hir::Crate::visit_all_item_likes
  49: rustc::util::common::time
  50: rustc_typeck::check_crate
  51: <std::thread::local::LocalKey<T>>::with
  52: rustc::ty::context::TyCtxt::create_and_enter
  53: rustc_driver::driver::compile_input
  54: rustc_driver::run_compiler_with_pool
  55: <scoped_tls::ScopedKey<T>>::set
  56: rustc_driver::run_compiler
  57: syntax::with_globals
  58: __rust_maybe_catch_panic
  59: <F as alloc::boxed::FnBox<A>>::call_box
  60: std::sys::unix::thread::Thread::new::thread_start
  61: _pthread_body
  62: _pthread_start
query stack during panic:
#0 [const_eval_raw] const-evaluating `A::field::{{constant}}`
#1 [const_eval] const-evaluating + checking `A::field::{{constant}}`
#2 [check_item_well_formed] processing `A`
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0015`.

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.34.0 (91856ed52 2019-04-10) running on x86_64-apple-darwin

@goddessfreya
Copy link
Contributor

Does not seam to even require a function:

#![feature(const_generics)]

struct NibblePack<const N: usize> ([u8; N / 1]);

Playground: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=18a496cff8cef0ae5f57d52a69d4a92a

Backtrace:

   Compiling farklemaster v0.1.0 (/home/gentz/Documents/gfx/farklemaster)
warning: the feature `const_generics` is incomplete and may cause the compiler to crash
 --> src/main.rs:1:12
  |
1 | #![feature(const_generics, untagged_unions)]
  |            ^^^^^^^^^^^^^^
  |
  = note: `#[warn(incomplete_features)]` on by default

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

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:578:9
stack backtrace:
   0:     0x7ff3551608e2 - backtrace::backtrace::libunwind::trace::hd6bd421890c8dc15
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/libunwind.rs:88
   1:     0x7ff3551608e2 - backtrace::backtrace::trace_unsynchronized::h5794e5e8aeae251a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.35/src/backtrace/mod.rs:66
   2:     0x7ff3551608e2 - std::sys_common::backtrace::_print::hac9caa5aa5e7e21f
                               at src/libstd/sys_common/backtrace.rs:47
   3:     0x7ff3551608e2 - std::sys_common::backtrace::print::hd000d0e9e39c8ae2
                               at src/libstd/sys_common/backtrace.rs:36
   4:     0x7ff3551608e2 - std::panicking::default_hook::{{closure}}::hbd4c7db8b4db9df0
                               at src/libstd/panicking.rs:200
   5:     0x7ff3551605c6 - std::panicking::default_hook::h01de047d1b30b7c3
                               at src/libstd/panicking.rs:214
   6:     0x7ff357045051 - rustc::util::common::panic_hook::h959c89d52f8e38a3
   7:     0x7ff35516111c - std::panicking::rust_panic_with_hook::h9c39618c52808332
                               at src/libstd/panicking.rs:481
   8:     0x7ff356fd3b5d - std::panicking::begin_panic::h733f239de789cec9
   9:     0x7ff356b176ed - rustc_errors::Handler::span_bug::hdbbf5b45f64a3a48
  10:     0x7ff356cf5d8e - rustc::util::bug::opt_span_bug_fmt::{{closure}}::h7b245dcf8371dcf6
  11:     0x7ff356cf0a13 - rustc::ty::context::tls::with_opt::{{closure}}::h3e31f0d12daf60e6
  12:     0x7ff356cf06b3 - rustc::ty::context::tls::with_context_opt::hc4b09da8394c7a33
  13:     0x7ff356cf06f7 - rustc::ty::context::tls::with_opt::hc886ba09634c690b
  14:     0x7ff356cf5c98 - rustc::util::bug::opt_span_bug_fmt::hb9038d097b69641d
  15:     0x7ff356cf5c4a - rustc::util::bug::span_bug_fmt::h2ea8aa55f8f30a61
  16:     0x7ff356b0143b - <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_const::hb48e47c51b05122f
  17:     0x7ff3560c1030 - rustc::traits::codegen::<impl rustc::ty::context::TyCtxt>::subst_and_normalize_erasing_regions::hd959ef59d4c7a154
  18:     0x7ff3561bfe07 - rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_operand::h5439d8be59fa7e84
  19:     0x7ff3561ce01c - rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run::h7748d8ea907f8dd2
  20:     0x7ff3560294fa - rustc_mir::const_eval::const_eval_raw_provider::h50f4217b07101ea6
  21:     0x7ff3560df453 - rustc::ty::query::__query_compute::const_eval_raw::h80089ae490de50d3
  22:     0x7ff35603753a - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval_raw>::compute::hfbe2000d47326943
  23:     0x7ff35618f2ff - rustc::dep_graph::graph::DepGraph::with_task_impl::h3d581bdb0f038452
  24:     0x7ff356048ddd - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h04f0276d1d39b5ce
  25:     0x7ff35602804e - rustc_mir::const_eval::const_eval_provider::h5ef25350ec6bfb7a
  26:     0x7ff3560de843 - rustc::ty::query::__query_compute::const_eval::hcfec520566953d99
  27:     0x7ff35603734a - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute::h15b53c1ead49c954
  28:     0x7ff356189dfa - rustc::dep_graph::graph::DepGraph::with_task_impl::h0722aefbbfab94b7
  29:     0x7ff35604c3bb - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h054986b9770876b7
  30:     0x7ff356027fdc - rustc_mir::const_eval::const_eval_provider::h5ef25350ec6bfb7a
  31:     0x7ff356b0f67a - rustc::ty::query::__query_compute::const_eval::h5400c26d8b541525
  32:     0x7ff356f06c8a - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::const_eval>::compute::h15b53c1ead49c954
  33:     0x7ff356a4e5d6 - rustc::dep_graph::graph::DepGraph::with_task_impl::h0ea8b6413eda918d
  34:     0x7ff356d5e114 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h336bbeabb89a5c31
  35:     0x7ff356f6240e - rustc::ty::sty::Const::eval::h4fdf07c982e42327
  36:     0x7ff356f454c1 - <rustc::traits::project::AssocTypeNormalizer as rustc::ty::fold::TypeFolder>::fold_ty::hd827ef16defe2054
  37:     0x7ff356f44713 - rustc::traits::project::normalize_with_depth::h10b5af39e0fe3c60
  38:     0x7ff357032db6 - rustc::traits::fully_normalize::hb8f66f19d4a2446a
  39:     0x7ff356efadbb - rustc::ty::context::GlobalCtxt::enter_local::hd3e03ea515f79db1
  40:     0x7ff356f5a001 - rustc::ty::util::<impl rustc::ty::ParamEnv>::can_type_implement_copy::heb7b7aded3373b0d
  41:     0x7ff355c917ec - rustc_typeck::coherence::builtin::check_trait::hcc1aeeaad417967b
  42:     0x7ff355e48559 - rustc_typeck::coherence::coherent_trait::ha4a271b5ca3a4a7c
  43:     0x7ff355c6f6aa - rustc::ty::query::__query_compute::coherent_trait::h2362077cee3c4017
  44:     0x7ff355d0304b - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::coherent_trait>::compute::h082442909284edf8
  45:     0x7ff355ca96ed - rustc::dep_graph::graph::DepGraph::with_task_impl::had495ae8aaa5b460
  46:     0x7ff355d7e1aa - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hf784bfb861e065c4
  47:     0x7ff355e48abc - rustc_typeck::coherence::check_coherence::h7d3c988311e2f6fb
  48:     0x7ff355c75516 - rustc::util::common::time::he8df946c085bb506
  49:     0x7ff355e4abb8 - rustc_typeck::check_crate::h364c57db6cf5f232
  50:     0x7ff35574729a - rustc_interface::passes::analysis::ha4ca96561e248eef
  51:     0x7ff3556348e1 - rustc::ty::query::__query_compute::analysis::hdc6f2eb00bbcb349
  52:     0x7ff355635bad - rustc::dep_graph::graph::DepGraph::with_task_impl::h772ba78078a0c1e4
  53:     0x7ff355645c8e - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h028ccb11c7ddf2a3
  54:     0x7ff35566631a - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::h12666f2fa53b6ad2
  55:     0x7ff3557c43da - rustc_interface::passes::create_global_ctxt::{{closure}}::hcb4b3b12c08b760f
  56:     0x7ff35566853e - rustc_interface::interface::run_compiler_in_existing_thread_pool::h6ec02d4511eb35d1
  57:     0x7ff355678022 - std::thread::local::LocalKey<T>::with::h062bc1d23e3251b0
  58:     0x7ff35568bd9e - scoped_tls::ScopedKey<T>::set::h437003735b7b6b10
  59:     0x7ff3556c0f12 - syntax::with_globals::hedfc891a8b9153ef
  60:     0x7ff35562f580 - std::sys_common::backtrace::__rust_begin_short_backtrace::h0e9208b9b24491cd
  61:     0x7ff3551717da - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:80
  62:     0x7ff355654149 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h220082988942ccab
  63:     0x7ff3551443df - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hf09088b4e23e576a
                               at /rustc/dfd43f0fdd4e6969c7d82c0670d70bf305fbccf8/src/liballoc/boxed.rs:922
  64:     0x7ff355170480 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hce7a5df2f9d13bbe
                               at /rustc/dfd43f0fdd4e6969c7d82c0670d70bf305fbccf8/src/liballoc/boxed.rs:922
  65:     0x7ff355170480 - std::sys_common::thread::start_thread::h29f82b1659010c48
                               at src/libstd/sys_common/thread.rs:13
  66:     0x7ff355170480 - std::sys::unix::thread::Thread::new::thread_start::hf8921307a11df38f
                               at src/libstd/sys/unix/thread.rs:79
  67:     0x7ff35507957f - start_thread
  68:     0x7ff354f8c0e3 - __clone
  69:                0x0 - <unknown>
query stack during panic:
#0 [const_eval_raw] const-evaluating `NibblePack::bytes::{{constant}}#0`
#1 [const_eval] const-evaluating + checking `NibblePack::bytes::{{constant}}#0`
#2 [const_eval] const-evaluating + checking `NibblePack::bytes::{{constant}}#0`
#3 [coherent_trait] coherence checking all impls of trait `std::marker::Copy`
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error


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.39.0-nightly (dfd43f0fd 2019-09-01) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 --crate-type bin

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

error: Could not compile `farklemaster`.

To learn more, run the command again with --verbose.

@goddessfreya
Copy link
Contributor

Other repo cases: #64048

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 15, 2019
@luojia65
Copy link
Contributor

luojia65 commented Nov 6, 2019

I came across this error too. My code:

pub struct Matrix<T, const R: usize, const C: usize> {
    inner: [T; R * C]
}

When compile, error occurred:

PS D:\RustProjects\frank-wolfe-prefer> cargo run --example local-storage --verbose
       Fresh cfg-if v0.1.10
       Fresh ppv-lite86 v0.2.6
       Fresh getrandom v0.1.13
       Fresh c2-chacha v0.2.3
       Fresh rand_core v0.5.1
       Fresh rand_chacha v0.2.1
       Fresh rand v0.7.2
   Compiling frank-wolfe-prefer v0.1.0 (D:\RustProjects\frank-wolfe-prefer)
     Running `rustc --edition=2018 --crate-name frank_wolfe_prefer src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=74fbd18809d153c3 -C extra-filename=-74fbd18809d153c3 --out-dir D:\RustProjects\frank-wolfe-prefer\target\debug\deps -C incremental=D:\RustProjects\frank-wolfe-prefer\target\debug\incremental -L dependency=D:\RustProjects\frank-wolfe-prefer\target\debug\deps --extern rand=D:\RustProjects\frank-wolfe-prefer\target\debug\deps\librand-93099efcd584b049.rmeta`
error: internal compiler error: src\librustc\ty\subst.rs:651: const parameter `R/#1` (Const { ty: usize, val: Param(R/#1) }/1) out of range when substituting substs=[]

thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:890:9
note: run with `RUST_BACKTRACE=1` environment variable to display a 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.40.0-nightly (1423bec54 2019-11-05) running on x86_64-pc-windows-msvc

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

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

error: aborting due to previous error

error: could not compile `frank-wolfe-prefer`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name frank_wolfe_prefer src\lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=74fbd18809d153c3 -C extra-filename=-74fbd18809d153c3 --out-dir D:\RustProjects\frank-wolfe-prefer\target\debug\deps -C incremental=D:\RustProjects\frank-wolfe-prefer\target\debug\incremental -L dependency=D:\RustProjects\frank-wolfe-prefer\target\debug\deps --extern rand=D:\RustProjects\frank-wolfe-prefer\target\debug\deps\librand-93099efcd584b049.rmeta` (exit code: 101)

Rust version:

PS D:\RustProjects\frank-wolfe-prefer> rustc -V
rustc 1.40.0-nightly (1423bec54 2019-11-05)

@aedoq
Copy link

aedoq commented Nov 18, 2019

I believe this is another instance of the error:

#![feature(const_generics)]
#![feature(const_compare_raw_pointers)]

fn func<A, const F: fn(inner: A)>(outer: A) {
    F(outer);
}

Backtrace:
RUST_BACKTRACE=full cargo build --verbose

   Compiling ice-test v0.1.0 ([...])
     Running `rustc --edition=2018 --crate-name ice_test src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=f3a24cbbef97f97a -C extra-filename=-f3a24cbbef97f97a --out-dir [...]/target/debug/deps -C incremental=[...]/target/debug/incremental -L dependency=[...]/target/debug/deps`
error: internal compiler error: src/librustc/ty/subst.rs:610: type parameter `A/#0` (A/0) out of range when substituting (root type=Some(fn(A))) substs=[]

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:845:9
stack backtrace:
   0:     0x7fe11bdf9a34 - backtrace::backtrace::libunwind::trace::h8c53309f22d88c8a
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1:     0x7fe11bdf9a34 - backtrace::backtrace::trace_unsynchronized::h6fd82dd611adbaf7
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2:     0x7fe11bdf9a34 - std::sys_common::backtrace::_print_fmt::h9030d1f31a3f4bb6
                               at src/libstd/sys_common/backtrace.rs:84
   3:     0x7fe11bdf9a34 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h63caf1987b315e75
                               at src/libstd/sys_common/backtrace.rs:61
   4:     0x7fe11be31f7c - core::fmt::write::ha838978e5554a3fd
                               at src/libcore/fmt/mod.rs:1030
   5:     0x7fe11bdeddc7 - std::io::Write::write_fmt::h9709be9e8aefaa67
                               at src/libstd/io/mod.rs:1412
   6:     0x7fe11bdfdede - std::sys_common::backtrace::_print::ha7997a59b8100963
                               at src/libstd/sys_common/backtrace.rs:65
   7:     0x7fe11bdfdede - std::sys_common::backtrace::print::h0e6bebe91d0af16b
                               at src/libstd/sys_common/backtrace.rs:50
   8:     0x7fe11bdfdede - std::panicking::default_hook::{{closure}}::h253a69014f4380df
                               at src/libstd/panicking.rs:188
   9:     0x7fe11bdfdbd1 - std::panicking::default_hook::h9903e5ad08e35d58
                               at src/libstd/panicking.rs:205
  10:     0x7fe11c322ed3 - rustc_driver::report_ice::h73c5774c65a339e0
  11:     0x7fe11bdfe6b0 - std::panicking::rust_panic_with_hook::h7fda44e006fd9fdb
                               at src/libstd/panicking.rs:468
  12:     0x7fe11de2913d - std::panicking::begin_panic::hd5bf2b3173a52cca
  13:     0x7fe11df472ba - rustc_errors::HandlerInner::span_bug::h089aba806cbdd369
  14:     0x7fe11df47b3a - rustc_errors::Handler::span_bug::h9be7751cca87b642
  15:     0x7fe11dcea5ae - rustc::util::bug::opt_span_bug_fmt::{{closure}}::hae1bc3a2d9f2c136
  16:     0x7fe11dce92d3 - rustc::ty::context::tls::with_opt::{{closure}}::h43e3789551ffc892
  17:     0x7fe11dce8fa3 - rustc::ty::context::tls::with_context_opt::h98ab1231a3b31ef6
  18:     0x7fe11dce8fe7 - rustc::ty::context::tls::with_opt::h0886b5e1cb2a2ade
  19:     0x7fe11dcea4b8 - rustc::util::bug::opt_span_bug_fmt::hfd2140e82a3785fe
  20:     0x7fe11dcea46a - rustc::util::bug::span_bug_fmt::h03c04fb296e4972a
  21:     0x7fe11da97faf - <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty::he25b479fa936b3d2
  22:     0x7fe11dab1f36 - <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter::h0bb7ca31d5f1319d
  23:     0x7fe11dd8425c - rustc::ty::fold::TypeFoldable::fold_with::h23c01612ac730b57
  24:     0x7fe11dda20be - rustc::ty::structural_impls::<impl rustc::ty::fold::TypeFoldable for &rustc::ty::TyS>::super_fold_with::hdc0a8805009b919b
  25:     0x7fe11da97d2e - <rustc::ty::subst::SubstFolder as rustc::ty::fold::TypeFolder>::fold_ty::he25b479fa936b3d2
  26:     0x7fe11c89e6c2 - rustc_typeck::check::FnCtxt::instantiate_value_path::hbb8487102544e9e2
  27:     0x7fe11c8670b5 - rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind::hac87f10cbb278c19
  28:     0x7fe11c86409b - rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs::hd93b46544b24a2f9
  29:     0x7fe11c87e7b9 - rustc_typeck::check::callee::<impl rustc_typeck::check::FnCtxt>::check_call::h62a4ecde155086f2
  30:     0x7fe11c864b4c - rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind::hac87f10cbb278c19
  31:     0x7fe11c86409b - rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs::hd93b46544b24a2f9
  32:     0x7fe11c89a389 - rustc_typeck::check::FnCtxt::check_stmt::h5aba78a030084850
  33:     0x7fe11c89a9db - rustc_typeck::check::FnCtxt::check_block_with_expected::h6a4dcd18788e61a5
  34:     0x7fe11c864b67 - rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_kind::hac87f10cbb278c19
  35:     0x7fe11c86409b - rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_expr_with_expectation_and_needs::hd93b46544b24a2f9
  36:     0x7fe11c86df9b - rustc_typeck::check::expr::<impl rustc_typeck::check::FnCtxt>::check_return_expr::h786ed8cdfb3041e1
  37:     0x7fe11c887f0f - rustc_typeck::check::check_fn::he2c2e43c32d58706
  38:     0x7fe11c9f6c0c - rustc::ty::context::tls::with_context::{{closure}}::h50e6d6cb9af96418
  39:     0x7fe11c886d1e - rustc_typeck::check::typeck_tables_of::hc70672beb76bdf97
  40:     0x7fe11c8fd2aa - rustc::ty::query::__query_compute::typeck_tables_of::hb8839e53cb93a3a2
  41:     0x7fe11c977b0b - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::typeck_tables_of>::compute::h7acd6750469c3b84
  42:     0x7fe11c92e312 - rustc::dep_graph::graph::DepGraph::with_task_impl::hbf45fe6c06d0bb6a
  43:     0x7fe11c985ed8 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h000d0542680a1237
  44:     0x7fe11c97422f - rustc::ty::<impl rustc::ty::context::TyCtxt>::par_body_owners::h8eff7b833346bd0e
  45:     0x7fe11c88674d - rustc_typeck::check::typeck_item_bodies::h08dfc65035cef777
  46:     0x7fe11c8fd6f5 - rustc::ty::query::__query_compute::typeck_item_bodies::h28e24bddd31d09b0
  47:     0x7fe11c92f604 - rustc::dep_graph::graph::DepGraph::with_task_impl::hdb02b90e73ec1b7f
  48:     0x7fe11c9d7c48 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::hf06fdbe7848d1f00
  49:     0x7fe11ca9f874 - rustc_typeck::check_crate::hbbaa02265f9abfd1
  50:     0x7fe11c3a9514 - rustc_interface::passes::analysis::h2e92fec7a93f5345
  51:     0x7fe11c2f8341 - rustc::ty::query::__query_compute::analysis::h8802febcbe5937d2
  52:     0x7fe11c2f9b01 - rustc::dep_graph::graph::DepGraph::with_task_impl::h1acefbafe76bf66d
  53:     0x7fe11c311566 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query::h5a1b63008bff09de
  54:     0x7fe11c30ec3a - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::hcb5ba44b71e57b24
  55:     0x7fe11c3d512a - rustc_interface::passes::create_global_ctxt::{{closure}}::habdec283a2026a49
  56:     0x7fe11c30e36e - rustc_interface::passes::BoxedGlobalCtxt::enter::h8e1c39c10064ea6f
  57:     0x7fe11c2d8880 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hb564b888470767db
  58:     0x7fe11c2e2aa1 - std::thread::local::LocalKey<T>::with::h2707847c2ea69d77
  59:     0x7fe11c2e443e - scoped_tls::ScopedKey<T>::set::h2134dafd21ff30c6
  60:     0x7fe11c2dfdc2 - syntax::with_globals::heb74cb8f2f2baa28
  61:     0x7fe11c2ea6e1 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd2c3273064cc913a
  62:     0x7fe11be0ef9a - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:81
  63:     0x7fe11c2ebd59 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h723616ac2301fe2c
  64:     0x7fe11bddfcff - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h70f621c89bd46176
                               at /rustc/0f0c640e0ee5a9ad365e78e3c62239b3d65b7045/src/liballoc/boxed.rs:942
  65:     0x7fe11be0d9c0 - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::h394f96b4177f765a
                               at /rustc/0f0c640e0ee5a9ad365e78e3c62239b3d65b7045/src/liballoc/boxed.rs:942
  66:     0x7fe11be0d9c0 - std::sys_common::thread::start_thread::haf8faa22fb2bc269
                               at src/libstd/sys_common/thread.rs:13
  67:     0x7fe11be0d9c0 - std::sys::unix::thread::Thread::new::thread_start::h09d290fc9c478975
                               at src/libstd/sys/unix/thread.rs:79
  68:     0x7fe11bd794cf - start_thread
  69:     0x7fe11bc962d3 - clone
  70:                0x0 - <unknown>

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 (0f0c640e0 2019-11-17) running on x86_64-unknown-linux-gnu

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 [typeck_tables_of] processing `func`
#1 [typeck_item_bodies] type-checking all item bodies
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `ice-test`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name ice_test src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C debuginfo=2 -C metadata=f3a24cbbef97f97a -C extra-filename=-f3a24cbbef97f97a --out-dir [...]/target/debug/deps -C incremental=[...]/target/debug/incremental -L dependency=[...]/target/debug/deps` (exit code: 101)

Version:
rustc --version --verbose

rustc 1.41.0-nightly (0f0c640e0 2019-11-17)
binary: rustc
commit-hash: 0f0c640e0ee5a9ad365e78e3c62239b3d65b7045
commit-date: 2019-11-17
host: x86_64-unknown-linux-gnu
release: 1.41.0-nightly
LLVM version: 9.0

@Alexendoo
Copy link
Member

Alexendoo commented Apr 16, 2020

Example in #58987 (comment) no longer ICEs as of #70452

#58987 (comment) still ICEs

@eddyb
Copy link
Member

eddyb commented Apr 16, 2020

@aedoq Uh oh that's a bug in const generics, type parameters aren't in scope for const parameters' types. cc @varkor @yodaldevoid

As for the other examples, I feel like this issue is just a duplicate of #43408.

@eddyb
Copy link
Member

eddyb commented Apr 16, 2020

@Alexendoo that's expected, #70452 only fixed repeat expressions ([expr; N]), not array types ([Type; N]).

@vnetserg
Copy link

This code produces ICE on both stable and nightly:

fn foo<T: ?Sized>(ptr: *const T) {
    let mut ptr_parts: [usize; std::mem::size_of::<*const T>() / std::mem::size_of::<usize>()]
        = unsafe { std::mem::transmute(ptr) };
}

Playground.

Looks related to the issue.

@eddyb
Copy link
Member

eddyb commented Apr 27, 2020

@vnetserg Yeah, that's textbook #43408. You can check by adding #![feature(const_generics)] at the top: if it changes the compiler's behavior at all, it's #43408 (we've included the backwards-incompatible-in-general trivial fix for #43408 into feature(const_generics) because const generics are very limited w/o it, and being opt-in means it can be backwards-incompatible).

I am closing this issue as a duplicate of #43408 (which by this point should have "array lengths" in its title renamed to "type-level constants").


@varkor @yodaldevoid we still need to open an issue for @aedoq's example in #58987 (comment)

@varkor
Copy link
Member

varkor commented Apr 27, 2020

@varkor @yodaldevoid we still need to open an issue for @aedoq's example in #58987 (comment)

Opened #71611.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests