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] with const generics without feature #79853

Closed
leonardo-m opened this issue Dec 9, 2020 · 3 comments
Closed

[ICE] with const generics without feature #79853

leonardo-m opened this issue Dec 9, 2020 · 3 comments
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) ❄️ P-medium Medium priority 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

@leonardo-m
Copy link

fn foo<const N: usize>(x: &[u8; N]) -> &[u8; N - 1] {
    match x { [_, ref xs @ ..] => xs }
}
fn main() {}

Gives:

error[E0658]: const generics are unstable
 --> ...\test.rs:1:14
  |
1 | fn foo<const N: usize>(x: &[u8; N]) -> &[u8; N - 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: internal compiler error: compiler\rustc_middle\src\ty\subst.rs:568:17: const parameter `N/#0` (Const { ty: usize, val: Param(N/#0) }/0) out of range when substituting substs=[]

thread 'rustc' panicked at 'Box<Any>', /rustc/1700ca07c6dd7becff85678409a5df6ad4cf4f47\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::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_opt
   6: rustc_middle::util::bug::opt_span_bug_fmt
   7: rustc_middle::util::bug::span_bug_fmt
   8: <rustc_middle::ty::subst::SubstFolder as rustc_middle::ty::fold::TypeFolder>::fold_const
   9: rustc_middle::ty::normalize_erasing_regions::<impl rustc_middle::ty::context::TyCtxt>::subst_and_normalize_erasing_regions
  10: rustc_mir::interpret::operand::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_operand
  11: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::eval_rvalue_into_place
  12: rustc_mir::interpret::step::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::run
  13: rustc_mir::const_eval::eval_queries::eval_to_allocation_raw_provider
  14: 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
  15: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  16: rustc_query_system::query::plumbing::get_query_impl
  17: rustc_mir::const_eval::eval_queries::eval_to_const_value_raw_provider
  18: 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
  19: rustc_middle::ty::query::plumbing::<impl rustc_query_system::query::QueryContext for rustc_middle::ty::context::TyCtxt>::start_query::{{closure}}::{{closure}}::{{closure}}
  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
  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_global_id
  27: rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_resolve
  28: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_const
  29: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  30: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_ty
  31: rustc_middle::ty::structural_impls::<impl rustc_middle::ty::fold::TypeFoldable for &rustc_middle::ty::TyS>::super_fold_with
  32: <rustc_trait_selection::traits::project::AssocTypeNormalizer as rustc_middle::ty::fold::TypeFolder>::fold_ty
  33: rustc_middle::ty::util::fold_list
  34: rustc_trait_selection::traits::project::AssocTypeNormalizer::fold
  35: rustc_trait_selection::traits::project::normalize
  36: <rustc_infer::infer::InferCtxt as rustc_trait_selection::infer::InferCtxtExt>::partially_normalize_associated_types_in
  37: rustc_typeck::check::inherited::Inherited::normalize_associated_types_in
  38: rustc_infer::infer::InferCtxtBuilder::enter
  39: rustc_typeck::check::wfcheck::check_item_fn
  40: rustc_typeck::check::wfcheck::check_item_well_formed
  41: 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
  42: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task
  43: rustc_data_structures::stack::ensure_sufficient_stack
  44: rustc_query_system::query::plumbing::get_query_impl
  45: rustc_query_system::query::plumbing::ensure_query_impl
  46: rustc_data_structures::sync::par_for_each_in
  47: rustc_hir::hir::Crate::par_visit_all_item_likes
  48: rustc_session::session::Session::track_errors
  49: rustc_typeck::check_crate
  50: rustc_interface::passes::analysis
  51: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  52: rustc_query_system::dep_graph::graph::DepGraph<K>::with_eval_always_task
  53: rustc_data_structures::stack::ensure_sufficient_stack
  54: rustc_query_system::query::plumbing::get_query_impl
  55: rustc_interface::passes::QueryContext::enter
  56: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  57: rustc_span::with_source_map
  58: rustc_interface::interface::create_compiler_and_run
  59: scoped_tls::ScopedKey<T>::set
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 (1700ca07c 2020-12-08) running on x86_64-pc-windows-gnu

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

For more information about this error, try `rustc --explain E0658`.
@leonardo-m leonardo-m added the C-bug Category: This is a bug. label Dec 9, 2020
@matthiaskrgr
Copy link
Member

This crashes on stable as well, and even on 1.44.
@rustbot label regression-from-stable-to-stable

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 9, 2020
@LeSeulArtichaut LeSeulArtichaut added A-const-generics Area: const generics (parameters and arguments) 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 9, 2020
@apiraino
Copy link
Contributor

apiraino commented Dec 9, 2020

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

@apiraino apiraino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Dec 9, 2020
@lcnr
Copy link
Contributor

lcnr commented Dec 9, 2020

this is a duplicate of #67945

will be fixed with #[feature(min_const_generics)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in 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) ❄️ P-medium Medium priority 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

No branches or pull requests

6 participants