Open
Description
auto-reduced (treereduce-rust):
#![feature(generic_const_exprs)]
trait A<const B: bool> {}
impl A<true> for () {}
fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
where
(): A<N>,
{
}
pub fn main() {
needs_a([]);
}
original:
//@ revisions: current next
//@[next] compile-flags: -Znext-solver
//@ ignore-compare-mode-next-solver (explicit revisions)
trait A<const B: bool> {}
impl A<true> for () {}
fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N]) where (): A<N> {}
//~^ ERROR the constant `N` is not of type `bool`
pub fn main() {
needs_a([]);
//~^ ERROR the constant `true` is not of type `usize`
//~| ERROR mismatched types
// FIXME(const_generics): we should hide this error as we've already errored above
}
Version information
rustc 1.86.0-nightly (43ca9d18e 2025-02-08)
binary: rustc
commit-hash: 43ca9d18e333797f0aa3b525501a7cec8d61a96b
commit-date: 2025-02-08
host: x86_64-unknown-linux-gnu
release: 1.86.0-nightly
LLVM version: 19.1.7
Possibly related line of code:
rust/compiler/rustc_const_eval/src/interpret/operator.rs
Lines 46 to 58 in 43ca9d1
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(generic_const_exprs)
Program output
error[E0261]: use of undeclared lifetime name `'a`
--> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:34
|
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `'a,`
error[E0261]: use of undeclared lifetime name `'a`
--> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:41
|
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
| - ^^ undeclared lifetime
| |
| help: consider introducing lifetime `'a` here: `'a,`
error[E0412]: cannot find type `T` in this scope
--> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:37
|
1 | trait A<const B: bool> {}
| ---------------------- similarly named trait `A` defined here
...
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
| ^
|
help: a trait with a similar name exists
|
5 | fn needs_a<const N: usize>(_: [(&'a A, &'a U); N * N])
| ~
help: you might be missing a type parameter
|
5 | fn needs_a<const N: usize, T>(_: [(&'a T, &'a U); N * N])
| +++
error[E0412]: cannot find type `U` in this scope
--> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:44
|
1 | trait A<const B: bool> {}
| ---------------------- similarly named trait `A` defined here
...
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
| ^
|
help: a trait with a similar name exists
|
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a A); N * N])
| ~
help: you might be missing a type parameter
|
5 | fn needs_a<const N: usize, U>(_: [(&'a T, &'a U); N * N])
| +++
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> <crate attribute>:1:9
|
1 | feature(generic_const_exprs)
| ^^^^^^^^^^^^^^^^^^^
|
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
= note: `#[warn(incomplete_features)]` on by default
error: the constant `N` is not of type `bool`
--> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:7:9
|
7 | (): A<N>,
| ^^^^ expected `bool`, found `usize`
|
note: required by a const generic parameter in `A`
--> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:1:9
|
1 | trait A<const B: bool> {}
| ^^^^^^^^^^^^^ required by this const generic parameter in `A`
error: internal compiler error: compiler/rustc_const_eval/src/interpret/operator.rs:52:18: Invalid operation on bool: MulWithOverflow
--> /tmp/icemaker_global_tempdir.Tw5KION65QBu/rustc_testrunner_tmpdir_reporting.KAL2r19SbBmX/mvce.rs:5:48
|
5 | fn needs_a<const N: usize>(_: [(&'a T, &'a U); N * N])
| ^^^^^
thread 'rustc' panicked at compiler/rustc_const_eval/src/interpret/operator.rs:52:18:
Box<dyn Any>
stack backtrace:
0: 0x73590802c500 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h1b226bb815bf78f5
1: 0x7359088146e8 - core::fmt::write::h5f68f60039d1d2a6
2: 0x735909b64791 - std::io::Write::write_fmt::h2f9a797f5ecd0cae
3: 0x73590802c362 - std::sys::backtrace::BacktraceLock::print::h0b9c3be369c24724
4: 0x73590802e7e2 - std::panicking::default_hook::{{closure}}::h793d3a348a3aeaff
5: 0x73590802e66a - std::panicking::default_hook::h56b0b57f5f9ffa8a
6: 0x735907188839 - std[3fff7a6371a6e7c2]::panicking::update_hook::<alloc[62c04a7c9cb01615]::boxed::Box<rustc_driver_impl[afdcaabde0c38b30]::install_ice_hook::{closure#1}>>::{closure#0}
7: 0x73590802f323 - std::panicking::rust_panic_with_hook::hcb5df778ecc712ed
8: 0x7359071c3bf1 - std[3fff7a6371a6e7c2]::panicking::begin_panic::<rustc_errors[70c172070bd433dc]::ExplicitBug>::{closure#0}
9: 0x7359071b8b66 - std[3fff7a6371a6e7c2]::sys::backtrace::__rust_end_short_backtrace::<std[3fff7a6371a6e7c2]::panicking::begin_panic<rustc_errors[70c172070bd433dc]::ExplicitBug>::{closure#0}, !>
10: 0x7359071b58e9 - std[3fff7a6371a6e7c2]::panicking::begin_panic::<rustc_errors[70c172070bd433dc]::ExplicitBug>
11: 0x7359071cdbc1 - <rustc_errors[70c172070bd433dc]::diagnostic::BugAbort as rustc_errors[70c172070bd433dc]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
12: 0x735907729d9c - <rustc_errors[70c172070bd433dc]::DiagCtxtHandle>::span_bug::<rustc_span[b8e92fef1403c7b]::span_encoding::Span, alloc[62c04a7c9cb01615]::string::String>
13: 0x7359077ab057 - rustc_middle[5a19c9913f5418cc]::util::bug::opt_span_bug_fmt::<rustc_span[b8e92fef1403c7b]::span_encoding::Span>::{closure#0}
14: 0x735907793bca - rustc_middle[5a19c9913f5418cc]::ty::context::tls::with_opt::<rustc_middle[5a19c9913f5418cc]::util::bug::opt_span_bug_fmt<rustc_span[b8e92fef1403c7b]::span_encoding::Span>::{closure#0}, !>::{closure#0}
15: 0x735907793a5b - rustc_middle[5a19c9913f5418cc]::ty::context::tls::with_context_opt::<rustc_middle[5a19c9913f5418cc]::ty::context::tls::with_opt<rustc_middle[5a19c9913f5418cc]::util::bug::opt_span_bug_fmt<rustc_span[b8e92fef1403c7b]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
16: 0x735905c3dff7 - rustc_middle[5a19c9913f5418cc]::util::bug::span_bug_fmt::<rustc_span[b8e92fef1403c7b]::span_encoding::Span>
17: 0x7359088a1f31 - <rustc_const_eval[e4956babb8e22105]::interpret::eval_context::InterpCx<rustc_const_eval[e4956babb8e22105]::const_eval::machine::CompileTimeMachine>>::binary_op
18: 0x7359093eba6b - <rustc_const_eval[e4956babb8e22105]::interpret::eval_context::InterpCx<rustc_const_eval[e4956babb8e22105]::const_eval::machine::CompileTimeMachine>>::eval_rvalue_into_place
19: 0x7359065818a9 - rustc_const_eval[e4956babb8e22105]::const_eval::eval_queries::eval_to_allocation_raw_provider
20: 0x735908ef975c - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_allocation_raw::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>
21: 0x735908ef90fa - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_query_system[cf17836f2ec93676]::query::caches::DefaultCache<rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
22: 0x735908ef8d7b - rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_allocation_raw::get_query_non_incr::__rust_end_short_backtrace
23: 0x735908eff16d - rustc_const_eval[e4956babb8e22105]::const_eval::valtrees::eval_to_valtree
24: 0x735908efef3e - <rustc_const_eval[e4956babb8e22105]::provide::{closure#0} as core[5ee9194023cfa8f]::ops::function::FnOnce<(rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt, rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>)>>::call_once
25: 0x735908efeed0 - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_valtree::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>
26: 0x735908efee89 - <rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_valtree::dynamic_query::{closure#2} as core[5ee9194023cfa8f]::ops::function::FnOnce<(rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt, rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>)>>::call_once
27: 0x735908ef91d3 - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_query_system[cf17836f2ec93676]::query::caches::DefaultCache<rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
28: 0x735908ef8b13 - rustc_query_impl[568d4bcab549c9ff]::query_impl::eval_to_valtree::get_query_non_incr::__rust_end_short_backtrace
29: 0x73590906724c - rustc_middle[5a19c9913f5418cc]::query::plumbing::query_get_at::<rustc_query_system[cf17836f2ec93676]::query::caches::DefaultCache<rustc_middle[5a19c9913f5418cc]::ty::PseudoCanonicalInput<rustc_middle[5a19c9913f5418cc]::mir::interpret::GlobalId>, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 24usize]>>>
30: 0x735909066862 - <rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt>::const_eval_global_id_for_typeck
31: 0x7359090666f9 - <rustc_middle[5a19c9913f5418cc]::ty::context::TyCtxt>::const_eval_resolve_for_typeck
32: 0x735909066437 - rustc_trait_selection[59d4f5ca90fd2e37]::traits::try_evaluate_const
33: 0x73590a48ddfc - rustc_trait_selection[59d4f5ca90fd2e37]::traits::const_evaluatable::is_const_evaluatable.cold
34: 0x7359091b80c2 - <rustc_trait_selection[59d4f5ca90fd2e37]::traits::fulfill::FulfillProcessor as rustc_data_structures[e2e7e2ff480ff884]::obligation_forest::ObligationProcessor>::process_obligation
35: 0x735908807a4b - <rustc_data_structures[e2e7e2ff480ff884]::obligation_forest::ObligationForest<rustc_trait_selection[59d4f5ca90fd2e37]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[59d4f5ca90fd2e37]::traits::fulfill::FulfillProcessor>
36: 0x73590892c7ea - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::try_structurally_resolve_type
37: 0x7359094a6a2b - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
38: 0x7359094a82bb - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
39: 0x7359094a174f - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_block
40: 0x7359094a91fe - <rustc_hir_typeck[1a28ab23194131d9]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
41: 0x735908cf55d7 - rustc_hir_typeck[1a28ab23194131d9]::check::check_fn
42: 0x735908cfe472 - rustc_hir_typeck[1a28ab23194131d9]::typeck_with_inspect::{closure#0}
43: 0x735908cfc44c - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 8usize]>>
44: 0x735908c01b4e - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_data_structures[e2e7e2ff480ff884]::vec_cache::VecCache<rustc_span[b8e92fef1403c7b]::def_id::LocalDefId, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[cf17836f2ec93676]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
45: 0x735908c00d1f - rustc_query_impl[568d4bcab549c9ff]::query_impl::typeck::get_query_non_incr::__rust_end_short_backtrace
46: 0x735908c009d9 - <rustc_middle[5a19c9913f5418cc]::hir::map::Map>::par_body_owners::<rustc_hir_analysis[3b61b7cada22afae]::check_crate::{closure#3}>::{closure#0}
47: 0x735908c00049 - rustc_hir_analysis[3b61b7cada22afae]::check_crate
48: 0x735908bfaba5 - rustc_interface[88e21834afb68210]::passes::run_required_analyses
49: 0x7359092f409e - rustc_interface[88e21834afb68210]::passes::analysis
50: 0x7359092f406f - rustc_query_impl[568d4bcab549c9ff]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[568d4bcab549c9ff]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 0usize]>>
51: 0x7359097d56d5 - rustc_query_system[cf17836f2ec93676]::query::plumbing::try_execute_query::<rustc_query_impl[568d4bcab549c9ff]::DynamicConfig<rustc_query_system[cf17836f2ec93676]::query::caches::SingleCache<rustc_middle[5a19c9913f5418cc]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[568d4bcab549c9ff]::plumbing::QueryCtxt, false>
52: 0x7359097d540e - rustc_query_impl[568d4bcab549c9ff]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
53: 0x735909748bab - rustc_interface[88e21834afb68210]::passes::create_and_enter_global_ctxt::<core[5ee9194023cfa8f]::option::Option<rustc_interface[88e21834afb68210]::queries::Linker>, rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
54: 0x7359097b989c - rustc_interface[88e21834afb68210]::interface::run_compiler::<(), rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}>::{closure#1}
55: 0x7359096af804 - std[3fff7a6371a6e7c2]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[88e21834afb68210]::util::run_in_thread_with_globals<rustc_interface[88e21834afb68210]::util::run_in_thread_pool_with_globals<rustc_interface[88e21834afb68210]::interface::run_compiler<(), rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
56: 0x7359096af4d9 - <<std[3fff7a6371a6e7c2]::thread::Builder>::spawn_unchecked_<rustc_interface[88e21834afb68210]::util::run_in_thread_with_globals<rustc_interface[88e21834afb68210]::util::run_in_thread_pool_with_globals<rustc_interface[88e21834afb68210]::interface::run_compiler<(), rustc_driver_impl[afdcaabde0c38b30]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[5ee9194023cfa8f]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
57: 0x7359096aec6f - std::sys::pal::unix::thread::Thread::new::thread_start::hb3b2c97ca272329f
58: 0x7359038a339d - <unknown>
59: 0x73590392849c - <unknown>
60: 0x0 - <unknown>
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: rustc 1.86.0-nightly (43ca9d18e 2025-02-08) running on x86_64-unknown-linux-gnu
note: compiler flags: -Z crate-attr=feature(generic_const_exprs) -Z dump-mir-dir=dir
query stack during panic:
#0 [eval_to_allocation_raw] const-evaluating + checking `needs_a::{constant#0}`
#1 [eval_to_valtree] evaluating type-level constant
#2 [typeck] type-checking `main`
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 6 previous errors; 1 warning emitted
Some errors have detailed explanations: E0261, E0412.
For more information about an error, try `rustc --explain E0261`.
@rustbot label +F-generic_const_exprs
Metadata
Metadata
Assignees
Labels
Category: This is a bug.`#![feature(generic_const_exprs)]`Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: Problems and improvements with respect to performance of generated code.Status: This bug is tracked inside the repo by a `known-bug` test.Relevant to the compiler team, which will review and decide on the PR/issue.