Skip to content

ICE: compiler/rustc_middle/src/ty/subst.rs:568:17: const parameter COUNT/#0 (Const { ty: usize, val: Param(COUNT/#0) }/0) out of range when substituting substs=[] #80375

New issue

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

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

Already on GitHub? # to your account

Closed
chengniansun opened this issue Dec 26, 2020 · 3 comments · Fixed by #80419
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

struct MyArray<const COUNT: usize>([u8; COUNT + 1]);

Meta

rustc --version --verbose:

rustc 1.50.0-nightly (bb178237c 2020-12-25)
binary: rustc
commit-hash: bb178237c5539c75e1b85ab78a8ab902b1f333d5
commit-date: 2020-12-25
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

Error output

error[E0658]: const generics are unstable
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:22
  |
1 | struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
  |                      ^^^^^
  |
  = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
  = help: add `#![feature(min_const_generics)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

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

thread 'rustc' panicked at 'Box<Any>', /rustc/bb178237c5539c75e1b85ab78a8ab902b1f333d5/compiler/rustc_errors/src/lib.rs:904: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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.50.0-nightly (bb178237c 2020-12-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `MyArray::0::{constant#0}`
#1 [eval_to_const_value_raw] simplifying constant for the type system `MyArray::0::{constant#0}`
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.
Backtrace

error[E0658]: const generics are unstable
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:22
  |
1 | struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
  |                      ^^^^^
  |
  = note: see issue #74878 <https://github.com/rust-lang/rust/issues/74878> for more information
  = help: add `#![feature(min_const_generics)]` to the crate attributes to enable

error[E0601]: `main` function not found in crate `perses_node_priority_with_dfs_delta_reduced_mutant`
 --> perses_node_priority_with_dfs_delta_reduced_mutant.rs:1:1
  |
1 | struct MyArray<const COUNT: usize>([u8; COUNT + 1]);
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ consider adding a `main` function to `perses_node_priority_with_dfs_delta_reduced_mutant.rs`

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

thread 'rustc' panicked at 'Box<Any>', /rustc/bb178237c5539c75e1b85ab78a8ab902b1f333d5/compiler/rustc_errors/src/lib.rs:904:9
stack backtrace:
   0: std::panicking::begin_panic
   1: rustc_errors::HandlerInner::span_bug
   2: rustc_errors::Handler::span_bug
   3: rustc_middle::ty::context::tls::with_opt
   4: rustc_middle::util::bug::opt_span_bug_fmt
   5: rustc_middle::util::bug::span_bug_fmt
   6: <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_const
   7: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
   8: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_operand
   9: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  10: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  11: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  12: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_allocation_raw>::compute
  13: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  14: rustc_data_structures::stack::ensure_sufficient_stack
  15: rustc_query_system::query::plumbing::get_query_impl
  16: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  17: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::get_query_impl
  21: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::eval_to_const_value_raw>::compute
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::get_query_impl
  26: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  27: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_const
  28: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  29: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_ty
  30: rustc_data_structures::stack::ensure_sufficient_stack
  31: rustc_trait_selection::traits::project::normalize
  32: <rustc_infer::infer::InferCtxt as rustc_trait_selection::infer::InferCtxtExt>::partially_normalize_associated_types_in
  33: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
  34: <alloc::vec::Vec<T> as alloc::vec::SpecFromIter<T,I>>::from_iter
  35: rustc_typeck::check::wfcheck::<impl rustc_typeck::check::fn_ctxt::FnCtxt>::non_enum_variant
  36: rustc_infer::infer::InferCtxtBuilder::enter
  37: rustc_typeck::check::wfcheck::check_item_well_formed
  38: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::check_item_well_formed>::compute
  39: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  40: rustc_data_structures::stack::ensure_sufficient_stack
  41: rustc_query_system::query::plumbing::get_query_impl
  42: rustc_query_system::query::plumbing::ensure_query_impl
  43: <rustc_typeck::check::wfcheck::CheckTypeWellFormedVisitor as rustc_hir::itemlikevisit::ParItemLikeVisitor>::visit_item
  44: rustc_data_structures::sync::par_for_each_in
  45: rustc_hir::hir::Crate::par_visit_all_item_likes
  46: rustc_session::session::Session::track_errors
  47: rustc_typeck::check_crate
  48: rustc_interface::passes::analysis
  49: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  50: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  51: rustc_data_structures::stack::ensure_sufficient_stack
  52: rustc_query_system::query::plumbing::get_query_impl
  53: rustc_interface::passes::QueryContext::enter
  54: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  55: rustc_span::with_source_map
  56: rustc_interface::interface::create_compiler_and_run
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.50.0-nightly (bb178237c 2020-12-25) running on x86_64-unknown-linux-gnu

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `MyArray::0::{constant#0}`
#1 [eval_to_const_value_raw] simplifying constant for the type system `MyArray::0::{constant#0}`
#2 [eval_to_const_value_raw] simplifying constant for the type system `MyArray::0::{constant#0}`
#3 [check_item_well_formed] checking that `MyArray` is well-formed
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0601, E0658.
For more information about an error, try `rustc --explain E0601`.

@chengniansun chengniansun added C-bug Category: This is a bug. 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. labels Dec 26, 2020
@LeSeulArtichaut
Copy link
Contributor

LeSeulArtichaut commented Dec 26, 2020

According to Godbolt, this regressed in 1.39.0.
Adding #![feature(min_const_generics)] removes the ICE on latest nightly, which I think means this will be fixed by min_const_generics stabilization in #79135. cc @lcnr

@LeSeulArtichaut LeSeulArtichaut added A-const-generics Area: const generics (parameters and arguments) I-prioritize Issue: Indicates that prioritization has been requested for this issue. regression-from-stable-to-stable Performance or correctness regression from one stable version to another. labels Dec 26, 2020
@camelid
Copy link
Member

camelid commented Dec 26, 2020

Note that it doesn't ICE on the latest nightly (2020-12-25) with #![feature(min_const_generics)], but it still errors out because it's not supported under min_const_generics.

@LeSeulArtichaut
Copy link
Contributor

This is indeed fixed on master. I'll file a PR to add a regression test for this.

LeSeulArtichaut added a commit to LeSeulArtichaut/rust that referenced this issue Dec 27, 2020
bors added a commit to rust-lang-ci/rust that referenced this issue Dec 29, 2020
Rollup of 11 pull requests

Successful merges:

 - rust-lang#80383 (clarify wrapping ptr arithmetic docs)
 - rust-lang#80390 (BTreeMap: rename the area access methods)
 - rust-lang#80393 (Add links to the source for the rustc and rustdoc books.)
 - rust-lang#80398 (Use raw version of align_of in rc data_offset)
 - rust-lang#80402 (Document `InferTy` & co.)
 - rust-lang#80403 (fix: small typo error in chalk/mod.rs)
 - rust-lang#80410 (rustdoc book: fix example)
 - rust-lang#80419 (Add regression test for rust-lang#80375)
 - rust-lang#80430 (Add "length" as doc alias to len methods)
 - rust-lang#80431 (Add "chr" as doc alias to char::from_u32)
 - rust-lang#80448 (Fix stabilization version of deque_range feature.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in a570928 Dec 29, 2020
@LeSeulArtichaut LeSeulArtichaut removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Dec 30, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-const-generics Area: const generics (parameters and arguments) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants