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: range start index 1 out of range for slice of length 1 in rustc_const_eval/src/interpret/terminator.rs #127304

Closed
Naserume opened this issue Jul 4, 2024 · 4 comments · Fixed by #127311
Labels
C-bug Category: This is a bug. F-adt_const_params `#![feature(adt_const_params)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Naserume
Copy link

Naserume commented Jul 4, 2024

Code

trait Trait<T> {}
impl Trait<u16> for () {}

#![feature(adt_const_params)]

struct MyStr(str);
impl std::marker::ConstParamTy for MyStr {}

fn function_with_my_str<const S: &'static MyStr>() -> &'static MyStr {
    S
}

impl MyStr {
    const fn new(s: &Trait str) -> &'static MyStr {}
}

pub fn main() {
    let f = function_with_my_str::<{ MyStr::new("hello") }>();
}

Meta

rustc --version --verbose:

rustc 1.81.0-nightly (6292b2af6 2024-07-02)
binary: rustc
commit-hash: 6292b2af620dbd771ebb687c3a93c69ba8f97268
commit-date: 2024-07-02
host: x86_64-apple-darwin
release: 1.81.0-nightly
LLVM version: 18.1.7

Error output

error: an inner attribute is not permitted in this context
 --> ./2F705.rs:4:1
  |
4 | #![feature(adt_const_params)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
7 | struct MyStr(str);
  | ------------------ the inner attribute doesn't annotate this struct
  |
  = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files
help: to annotate the struct, change the attribute from inner to outer style
  |
4 - #![feature(adt_const_params)]
4 + #[feature(adt_const_params)]
  |

error: expected one of `:`, `@`, or `|`, found `)`
  --> ./2F705.rs:15:31
   |
15 |     const fn new(s: &Trait str) -> &'static MyStr {}
   |                               ^ expected one of `:`, `@`, or `|`
   |
   = note: anonymous parameters are removed in the 2018 edition (see RFC 1685)
help: if this is a parameter name, give it a type
   |
15 |     const fn new(s: &Trait str: TypeName) -> &'static MyStr {}
   |                               ++++++++++
help: if this is a type, explicitly ignore the parameter name
   |
15 |     const fn new(s: &Trait _: str) -> &'static MyStr {}
   |                            ++

error: expected one of `!`, `(`, `)`, `,`, `::`, or `<`, found `str`
  --> ./2F705.rs:15:28
   |
15 |     const fn new(s: &Trait str) -> &'static MyStr {}
   |                           -^^^ expected one of `!`, `(`, `)`, `,`, `::`, or `<`
   |                           |
   |                           help: missing `,`

error[E0658]: use of unstable library feature 'adt_const_params'
 --> ./2F705.rs:8:6
  |
8 | impl std::marker::ConstParamTy for MyStr {}
  |      ^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
  = help: add `#![feature(adt_const_params)]` to the crate attributes to enable
  = note: this compiler was built on 2024-07-02; consider upgrading it if it is out of date

error[E0277]: the trait bound `MyStr: Eq` is not satisfied
   --> ./2F705.rs:8:36
    |
8   | impl std::marker::ConstParamTy for MyStr {}
    |                                    ^^^^^ the trait `Eq` is not implemented for `MyStr`
    |
note: required by a bound in `ConstParamTy`
   --> /Users/sal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/marker.rs:981:47
    |
981 | pub trait ConstParamTy: StructuralPartialEq + Eq {}
    |                                               ^^ required by this bound in `ConstParamTy`
help: consider annotating `MyStr` with `#[derive(Eq)]`
    |
7   + #[derive(Eq)]
8   | struct MyStr(str);
    |

error[E0277]: the type `MyStr` does not `#[derive(PartialEq)]`
   --> ./2F705.rs:8:36
    |
8   | impl std::marker::ConstParamTy for MyStr {}
    |                                    ^^^^^ the trait `StructuralPartialEq` is not implemented for `MyStr`
    |
note: required by a bound in `ConstParamTy`
   --> /Users/sal/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/marker.rs:981:25
    |
981 | pub trait ConstParamTy: StructuralPartialEq + Eq {}
    |                         ^^^^^^^^^^^^^^^^^^^ required by this bound in `ConstParamTy`

error: `&'static MyStr` is forbidden as the type of a const generic parameter
  --> ./2F705.rs:10:34
   |
10 | fn function_with_my_str<const S: &'static MyStr>() -> &'static MyStr {
   |                                  ^^^^^^^^^^^^^^
   |
   = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
   |
1  + #![feature(adt_const_params)]
   |

warning: trait objects without an explicit `dyn` are deprecated
  --> ./2F705.rs:15:22
   |
15 |     const fn new(s: &Trait str) -> &'static MyStr {}
   |                      ^^^^^
   |
   = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
   = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
   = note: `#[warn(bare_trait_objects)]` on by default
help: if this is an object-safe trait, use `dyn`
   |
15 |     const fn new(s: &dyn Trait str) -> &'static MyStr {}
   |                      +++

error[E0107]: missing generics for trait `Trait`
  --> ./2F705.rs:15:22
   |
15 |     const fn new(s: &Trait str) -> &'static MyStr {}
   |                      ^^^^^ expected 1 generic argument
   |
note: trait defined here, with 1 generic parameter: `T`
  --> ./2F705.rs:1:7
   |
1  | trait Trait<T> {}
   |       ^^^^^ -
help: add missing generic argument
   |
15 |     const fn new(s: &Trait<T> str) -> &'static MyStr {}
   |                           +++

error[E0308]: mismatched types
  --> ./2F705.rs:15:36
   |
15 |     const fn new(s: &Trait str) -> &'static MyStr {}
   |              ---                   ^^^^^^^^^^^^^^ expected `&MyStr`, found `()`
   |              |
   |              implicitly returns `()` as its body has no tail or `return` expression

Backtrace

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/terminator.rs:133:39:
range start index 2 out of range for slice of length 1
stack backtrace:
   0:        0x1091f2d93 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9393e218f71d31cf
   1:        0x10923e17b - core::fmt::write::h1271a75a7bae980c
   2:        0x1091e8c3e - std::io::Write::write_fmt::h8270e961acbabe61
   3:        0x1091f2b81 - std::sys::backtrace::print::h04e4916ebe343f6e
   4:        0x1091f5959 - std::panicking::default_hook::{{closure}}::hc9df26d29e0f9e5a
   5:        0x1091f56da - std::panicking::default_hook::h1026261fa8b9d0a8
   6:        0x1124dd0ac - std[26270defc80edaa9]::panicking::update_hook::<alloc[98df03226deedbda]::boxed::Box<rustc_driver_impl[708b2ec565622c48]::install_ice_hook::{closure#0}>>::{closure#0}
   7:        0x1091f6699 - std::panicking::rust_panic_with_hook::hf72d729757d375cc
   8:        0x1091f5ed5 - std::panicking::begin_panic_handler::{{closure}}::h5eb191147adf0e0d
   9:        0x1091f3269 - std::sys::backtrace::__rust_end_short_backtrace::he8eea0af09eba22f
  10:        0x1091f5aec - _rust_begin_unwind
  11:        0x1092594ca - core::panicking::panic_fmt::h403139b1d3f51ed8
  12:        0x109259b36 - core::slice::index::slice_start_index_len_fail::h58e498803150e5af
  13:        0x11244b12a - <rustc_const_eval[396cbee6e07433a6]::interpret::eval_context::InterpCx<rustc_const_eval[396cbee6e07433a6]::const_eval::machine::CompileTimeMachine>>::terminator
  14:        0x112462f56 - rustc_const_eval[396cbee6e07433a6]::const_eval::eval_queries::eval_to_allocation_raw_provider
  15:        0x113b9aaec - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>
  16:        0x113b4fbae - <rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<(rustc_middle[8094f41c293b336b]::ty::context::TyCtxt, rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>)>>::call_once
  17:        0x1139b3c0d - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  18:        0x113bc59dc - rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  19:        0x112393752 - rustc_middle[8094f41c293b336b]::query::plumbing::query_get_at::<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>>
  20:        0x11240f281 - rustc_const_eval[396cbee6e07433a6]::const_eval::valtrees::eval_to_valtree
  21:        0x112e34fe3 - <rustc_const_eval[396cbee6e07433a6]::provide::{closure#0} as core[c342ec502b95801]::ops::function::FnOnce<(rustc_middle[8094f41c293b336b]::ty::context::TyCtxt, rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>)>>::call_once
  22:        0x113b97d6c - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>
  23:        0x113b329de - <rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<(rustc_middle[8094f41c293b336b]::ty::context::TyCtxt, rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>)>>::call_once
  24:        0x1139b3c0d - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  25:        0x113bc671c - rustc_query_impl[36fa5edae9172c7f]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
  26:        0x11321df16 - rustc_middle[8094f41c293b336b]::query::plumbing::query_get_at::<rustc_query_system[16c7cab3586fd5d4]::query::caches::DefaultCache<rustc_middle[8094f41c293b336b]::ty::ParamEnvAnd<rustc_middle[8094f41c293b336b]::mir::interpret::GlobalId>, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 24usize]>>>
  27:        0x113222208 - <rustc_middle[8094f41c293b336b]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
  28:        0x113221bc2 - <rustc_middle[8094f41c293b336b]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
  29:        0x1140b4f71 - <rustc_middle[8094f41c293b336b]::ty::consts::Const>::eval
  30:        0x114174e82 - rustc_trait_selection[e5babfdcefab668e]::traits::util::with_replaced_escaping_bound_vars::<rustc_middle[8094f41c293b336b]::ty::consts::Const, rustc_middle[8094f41c293b336b]::ty::consts::Const, <rustc_trait_selection[e5babfdcefab668e]::traits::normalize::AssocTypeNormalizer as rustc_type_ir[52f1f4e14ae618a5]::fold::TypeFolder<rustc_middle[8094f41c293b336b]::ty::context::TyCtxt>>::fold_const::{closure#0}>
  31:        0x1129c8d78 - <&rustc_middle[8094f41c293b336b]::ty::list::RawList<(), rustc_middle[8094f41c293b336b]::ty::generic_args::GenericArg> as rustc_type_ir[52f1f4e14ae618a5]::fold::TypeFoldable<rustc_middle[8094f41c293b336b]::ty::context::TyCtxt>>::try_fold_with::<rustc_trait_selection[e5babfdcefab668e]::traits::normalize::AssocTypeNormalizer>
  32:        0x1129e8f72 - rustc_trait_selection[e5babfdcefab668e]::traits::normalize::normalize_with_depth_to::<&rustc_middle[8094f41c293b336b]::ty::list::RawList<(), rustc_middle[8094f41c293b336b]::ty::generic_args::GenericArg>>::{closure#0}
  33:        0x112abd06a - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::normalize::<&rustc_middle[8094f41c293b336b]::ty::list::RawList<(), rustc_middle[8094f41c293b336b]::ty::generic_args::GenericArg>>
  34:        0x112b82dfd - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::instantiate_value_path
  35:        0x112a97dc5 - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_expr_path
  36:        0x112a9718e - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  37:        0x112b67f45 - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_expr_kind
  38:        0x112a972aa - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  39:        0x112ad6930 - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_decl
  40:        0x112ad738c - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_block_with_expected
  41:        0x112a972aa - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  42:        0x112a993b4 - <rustc_hir_typeck[83a831c03ea981a4]::fn_ctxt::FnCtxt>::check_return_expr
  43:        0x112b56b3a - rustc_hir_typeck[83a831c03ea981a4]::check::check_fn
  44:        0x112b522e1 - rustc_hir_typeck[83a831c03ea981a4]::typeck
  45:        0x113b9d43c - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 8usize]>>
  46:        0x113a210fe - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::VecCache<rustc_span[2de937bbddea0bd8]::def_id::LocalDefId, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  47:        0x113bc0abb - rustc_query_impl[36fa5edae9172c7f]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
  48:        0x112756fd6 - <rustc_middle[8094f41c293b336b]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[af0a509199b1bc4b]::check_crate::{closure#4}>::{closure#0}
  49:        0x1128ac55c - rustc_hir_analysis[af0a509199b1bc4b]::check_crate
  50:        0x112e53df7 - rustc_interface[eab3c32d3b591e25]::passes::run_required_analyses
  51:        0x112e563a0 - rustc_interface[eab3c32d3b591e25]::passes::analysis
  52:        0x113b9d4ec - rustc_query_impl[36fa5edae9172c7f]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[36fa5edae9172c7f]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 1usize]>>
  53:        0x11397bfbe - rustc_query_system[16c7cab3586fd5d4]::query::plumbing::try_execute_query::<rustc_query_impl[36fa5edae9172c7f]::DynamicConfig<rustc_query_system[16c7cab3586fd5d4]::query::caches::SingleCache<rustc_middle[8094f41c293b336b]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[36fa5edae9172c7f]::plumbing::QueryCtxt, false>
  54:        0x113ba7a47 - rustc_query_impl[36fa5edae9172c7f]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  55:        0x112486857 - <rustc_interface[eab3c32d3b591e25]::queries::QueryResult<&rustc_middle[8094f41c293b336b]::ty::context::GlobalCtxt>>::enter::<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}::{closure#1}::{closure#5}>
  56:        0x1124e4465 - rustc_interface[eab3c32d3b591e25]::interface::run_compiler::<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}
  57:        0x1124caee1 - std[26270defc80edaa9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_with_globals<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_pool_with_globals<rustc_interface[eab3c32d3b591e25]::interface::run_compiler<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>
  58:        0x1124eaff6 - <<std[26270defc80edaa9]::thread::Builder>::spawn_unchecked_<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_with_globals<rustc_interface[eab3c32d3b591e25]::util::run_in_thread_pool_with_globals<rustc_interface[eab3c32d3b591e25]::interface::run_compiler<core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>, rustc_driver_impl[708b2ec565622c48]::run_compiler::{closure#0}>::{closure#1}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[c342ec502b95801]::result::Result<(), rustc_span[2de937bbddea0bd8]::ErrorGuaranteed>>::{closure#2} as core[c342ec502b95801]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  59:        0x1091ff83b - std::sys::pal::unix::thread::Thread::new::thread_start::hfcd29f6cc9954faa
  60:     0x7ff801f5318b - __pthread_start

error: 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: please make sure that you have updated to the latest nightly

note: please attach the file at `/Users/240701-nightly/rustc-ice-2024-07-04T07_01_14-84256.txt` to your bug report

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `main::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
end of query stack
error: aborting due to 9 previous errors; 1 warning emitted

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

Note

Ice location:

let fn_sig_binder = func.layout.ty.fn_sig(*self.tcx);
let fn_sig =
self.tcx.normalize_erasing_late_bound_regions(self.param_env, fn_sig_binder);
let extra_args = &args[fn_sig.inputs().len()..];
let extra_args =
self.tcx.mk_type_list_from_iter(extra_args.iter().map(|arg| arg.layout().ty));

@rustbot label +F-adt_const_params

@Naserume Naserume 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 Jul 4, 2024
@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. F-adt_const_params `#![feature(adt_const_params)]` labels Jul 4, 2024
@theemathas
Copy link

theemathas commented Jul 5, 2024

Minimized:

struct Foo<const B: bool>;

const fn bar(_: Foo, _: i32) {}

const X: () = bar(());
Error output
   Compiling playground v0.0.1 (/playground)
error[E0107]: missing generics for struct `Foo`
 --> src/lib.rs:3:17
  |
3 | const fn bar(_: Foo, _: i32) {}
  |                 ^^^ expected 1 generic argument
  |
note: struct defined here, with 1 generic parameter: `B`
 --> src/lib.rs:1:8
  |
1 | struct Foo<const B: bool>;
  |        ^^^ -------------
help: add missing generic argument
  |
3 | const fn bar(_: Foo<B>, _: i32) {}
  |                    +++

thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/terminator.rs:133:39:
range start index 2 out of range for slice of length 1
stack backtrace:
   0:     0x7f3570f733f5 - std::backtrace_rs::backtrace::libunwind::trace::h6192a0515770cb68
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x7f3570f733f5 - std::backtrace_rs::backtrace::trace_unsynchronized::h47eec72f82d8cae7
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f3570f733f5 - std::sys::backtrace::_print_fmt::hfc245a549fa1b401
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/sys/backtrace.rs:68:5
   3:     0x7f3570f733f5 - <std::sys::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hb5373740c5e73fea
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/sys/backtrace.rs:44:22
   4:     0x7f3570fc2afb - core::fmt::rt::Argument::fmt::h2ce03aea95173774
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/core/src/fmt/rt.rs:173:76
   5:     0x7f3570fc2afb - core::fmt::write::h5a5c06b51bcdd584
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/core/src/fmt/mod.rs:1174:21
   6:     0x7f3570f67f9f - std::io::Write::write_fmt::h7291b0d1d33b0d22
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/io/mod.rs:1835:15
   7:     0x7f3570f731ce - std::sys::backtrace::_print::h80cdd6872fa4b8a0
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/sys/backtrace.rs:47:5
   8:     0x7f3570f731ce - std::sys::backtrace::print::h544cdeff52bbef07
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/sys/backtrace.rs:34:9
   9:     0x7f3570f75b19 - std::panicking::default_hook::{{closure}}::hb3d70a45007289ae
  10:     0x7f3570f758bc - std::panicking::default_hook::h87c54ec30d00705a
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/panicking.rs:292:9
  11:     0x7f35743c971a - std[94a242da6872fff3]::panicking::update_hook::<alloc[9a4f59f7b28643c1]::boxed::Box<rustc_driver_impl[a0c20c88428f09f4]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f3570f7643f - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h27e8e6c7b2acf5a9
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/alloc/src/boxed.rs:2078:9
  13:     0x7f3570f7643f - std::panicking::rust_panic_with_hook::hee0a9cab1ca6d2cf
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/panicking.rs:804:13
  14:     0x7f3570f76067 - std::panicking::begin_panic_handler::{{closure}}::heffbac09c65e0601
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/panicking.rs:670:13
  15:     0x7f3570f738b9 - std::sys::backtrace::__rust_end_short_backtrace::h1809cdf434b5104c
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/sys/backtrace.rs:171:18
  16:     0x7f3570f75cf4 - rust_begin_unwind
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/panicking.rs:661:5
  17:     0x7f3570fbf0b3 - core::panicking::panic_fmt::hfb8b6fbd6440bc80
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/core/src/panicking.rs:74:14
  18:     0x7f3570fc51e7 - core::slice::index::slice_start_index_len_fail_rt::h87b5be3c684fa1e0
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/core/src/slice/index.rs:43:5
  19:     0x7f3570fc51e7 - core::slice::index::slice_start_index_len_fail::hd2b0efde3841da2a
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/core/src/slice/index.rs:36:5
  20:     0x7f357659ee1a - rustc_const_eval[313a3ee1fa7e52a8]::const_eval::eval_queries::eval_to_allocation_raw_provider
  21:     0x7f357659b176 - rustc_query_impl[1eb3b4e5729073b2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1eb3b4e5729073b2]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d8502f807578e519]::query::erase::Erased<[u8; 24usize]>>
  22:     0x7f3576594f51 - rustc_query_system[e883df6dd9e006ed]::query::plumbing::try_execute_query::<rustc_query_impl[1eb3b4e5729073b2]::DynamicConfig<rustc_query_system[e883df6dd9e006ed]::query::caches::DefaultCache<rustc_middle[d8502f807578e519]::ty::ParamEnvAnd<rustc_middle[d8502f807578e519]::mir::interpret::GlobalId>, rustc_middle[d8502f807578e519]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[1eb3b4e5729073b2]::plumbing::QueryCtxt, false>
  23:     0x7f3576594b30 - rustc_query_impl[1eb3b4e5729073b2]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
  24:     0x7f3576596d9e - rustc_const_eval[313a3ee1fa7e52a8]::const_eval::eval_queries::eval_to_const_value_raw_provider
  25:     0x7f3576596bb6 - rustc_query_impl[1eb3b4e5729073b2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1eb3b4e5729073b2]::query_impl::eval_to_const_value_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d8502f807578e519]::query::erase::Erased<[u8; 24usize]>>
  26:     0x7f3576594f14 - rustc_query_system[e883df6dd9e006ed]::query::plumbing::try_execute_query::<rustc_query_impl[1eb3b4e5729073b2]::DynamicConfig<rustc_query_system[e883df6dd9e006ed]::query::caches::DefaultCache<rustc_middle[d8502f807578e519]::ty::ParamEnvAnd<rustc_middle[d8502f807578e519]::mir::interpret::GlobalId>, rustc_middle[d8502f807578e519]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[1eb3b4e5729073b2]::plumbing::QueryCtxt, false>
  27:     0x7f3576594a30 - rustc_query_impl[1eb3b4e5729073b2]::query_impl::eval_to_const_value_raw::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7f3575c200b6 - <rustc_middle[d8502f807578e519]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[42e3b110e6e394ba]::check_crate::{closure#3}>::{closure#0}
  29:     0x7f3575c1d858 - rustc_hir_analysis[42e3b110e6e394ba]::check_crate
  30:     0x7f3575f132d5 - rustc_interface[dda9ae364c38123d]::passes::analysis
  31:     0x7f3575f12e9b - rustc_query_impl[1eb3b4e5729073b2]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[1eb3b4e5729073b2]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[d8502f807578e519]::query::erase::Erased<[u8; 1usize]>>
  32:     0x7f35768d3565 - rustc_query_system[e883df6dd9e006ed]::query::plumbing::try_execute_query::<rustc_query_impl[1eb3b4e5729073b2]::DynamicConfig<rustc_query_system[e883df6dd9e006ed]::query::caches::SingleCache<rustc_middle[d8502f807578e519]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[1eb3b4e5729073b2]::plumbing::QueryCtxt, false>
  33:     0x7f35768d32cf - rustc_query_impl[1eb3b4e5729073b2]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  34:     0x7f35767e7747 - rustc_interface[dda9ae364c38123d]::interface::run_compiler::<core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>, rustc_driver_impl[a0c20c88428f09f4]::run_compiler::{closure#0}>::{closure#1}
  35:     0x7f357676c389 - std[94a242da6872fff3]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dda9ae364c38123d]::util::run_in_thread_with_globals<rustc_interface[dda9ae364c38123d]::util::run_in_thread_pool_with_globals<rustc_interface[dda9ae364c38123d]::interface::run_compiler<core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>, rustc_driver_impl[a0c20c88428f09f4]::run_compiler::{closure#0}>::{closure#1}, core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>>::{closure#0}, core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>>
  36:     0x7f357676c13a - <<std[94a242da6872fff3]::thread::Builder>::spawn_unchecked_<rustc_interface[dda9ae364c38123d]::util::run_in_thread_with_globals<rustc_interface[dda9ae364c38123d]::util::run_in_thread_pool_with_globals<rustc_interface[dda9ae364c38123d]::interface::run_compiler<core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>, rustc_driver_impl[a0c20c88428f09f4]::run_compiler::{closure#0}>::{closure#1}, core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>>::{closure#0}, core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[855c82851c117839]::result::Result<(), rustc_span[2c8a00ae1af8c6af]::ErrorGuaranteed>>::{closure#2} as core[855c82851c117839]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7f3570f8029b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3d5e06604d1965c2
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/alloc/src/boxed.rs:2064:9
  38:     0x7f3570f8029b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h508510ab436163fe
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/alloc/src/boxed.rs:2064:9
  39:     0x7f3570f8029b - std::sys::pal::unix::thread::Thread::new::thread_start::ha123f5b6b8a5a5a3
                               at /rustc/aa1d4f6826de006b02fed31a718ce4f674203721/library/std/src/sys/pal/unix/thread.rs:108:17
  40:     0x7f3570e8a609 - start_thread
  41:     0x7f3570dad353 - clone
  42:                0x0 - <unknown>

error: 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: please make sure that you have updated to the latest nightly

note: please attach the file at `/playground/rustc-ice-2024-07-05T03_00_55-43.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

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

query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `X`
#1 [eval_to_const_value_raw] simplifying constant for the type system `X`
end of query stack
For more information about this error, try `rustc --explain E0107`.
error: could not compile `playground` (lib) due to 1 previous error

This ICE occurs in nightly but not in stable or beta.

@rustbot labels -F-adt_const_params +regression-from-stable-to-nightly

@rustbot rustbot added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. I-prioritize Issue: Indicates that prioritization has been requested for this issue. and removed F-adt_const_params `#![feature(adt_const_params)]` labels Jul 5, 2024
@apiraino
Copy link
Contributor

apiraino commented Jul 5, 2024

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Jul 5, 2024
@apiraino
Copy link
Contributor

apiraino commented Jul 5, 2024

Bisecting the second smaller repro brings us to 7b21c18 cc @oli-obk @nnethercote

searched nightlies: from nightly-2024-06-01 to nightly-2024-07-05
regressed nightly: nightly-2024-07-02
searched commit range: 6868c83...cf2df68
regressed commit: 7b21c18

bisected with cargo-bisect-rustc v0.6.8

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --without-cargo --preserve --start=2024-06-01 --script script.sh 

@oli-obk oli-obk removed the regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. label Jul 5, 2024
@oli-obk
Copy link
Contributor

oli-obk commented Jul 5, 2024

We don't track error -> ICE as regressions if there still is a useful error before the ICE

@matthiaskrgr matthiaskrgr added the S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. label Jul 5, 2024
@scottmcm scottmcm added the F-adt_const_params `#![feature(adt_const_params)]` label Jul 10, 2024
@bors bors closed this as completed in c92a8e4 Jul 11, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-adt_const_params `#![feature(adt_const_params)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority S-bug-has-test Status: This bug is tracked inside the repo by a `known-bug` test. 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.

8 participants