Skip to content

ICE: try_lower_anon_const_lit: received const param which shouldn't be possible with generic_const_exprs #140275

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

Open
wychlw opened this issue Apr 25, 2025 · 0 comments
Labels
C-bug Category: This is a bug. F-generic_const_exprs `#![feature(generic_const_exprs)]` 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

@wychlw
Copy link

wychlw commented Apr 25, 2025

Following issue may related:

  • The #137888
  • And also #127972
    Above issue happens in func sig instead of trait, but also want's to get the size of the array?

Code

#![feature(generic_const_exprs)]
trait T{}
trait V{}
impl<const N: i32> T for [i32; N::<&mut V>] {} 

A fuzzer is used, with manual minimize

Meta

rustc --version --verbose:

rustc 1.88.0-nightly (df35ff6c3 2025-04-23)
binary: rustc
commit-hash: df35ff6c354f1f1fbf430b84e7dea37dfe997f34
commit-date: 2025-04-23
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2

Error output

error: internal compiler error: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2536:13: try_lower_anon_const_lit: received const param which shouldn't be possible
 --> results/2.rs:4:32
  |
4 | impl<const N: i32> T for [i32; N::<&mut V>] {} 
  |                                ^^^^^^^^^^^


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2536:13:
Box<dyn Any>
...
query stack during panic:
#0 [type_of] computing type of `<impl at results/2.rs:4:1: 4:44>`
#1 [trait_impls_of] finding trait impls of `T`
#2 [check_well_formed] checking that `T` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
Backtrace

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> results/2.rs:1:12
  |
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: internal compiler error: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2536:13: try_lower_anon_const_lit: received const param which shouldn't be possible
 --> results/2.rs:4:32
  |
4 | impl<const N: i32> T for [i32; N::<&mut V>] {} 
  |                                ^^^^^^^^^^^


thread 'rustc' panicked at compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:2536:13:
Box<dyn Any>
stack backtrace:
   0:     0x7c354e0d3aa3 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h69244135d6875fb2
   1:     0x7c354e805ac7 - core::fmt::write::h8f228de95b735da4
   2:     0x7c354fc38391 - std::io::Write::write_fmt::hb10b33e03dac9dbe
   3:     0x7c354e0d3902 - std::sys::backtrace::BacktraceLock::print::hc0088d579301e87b
   4:     0x7c354e0d727a - std::panicking::default_hook::{{closure}}::hf9e3ab0f550f7255
   5:     0x7c354e0d6dff - std::panicking::default_hook::hde8dcea18bdfa1fc
   6:     0x7c354d156f23 - std[de55bbf40c15c1d9]::panicking::update_hook::<alloc[63d4616c10cc4540]::boxed::Box<rustc_driver_impl[60c1a2efe706eb75]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7c354e0d7af3 - std::panicking::rust_panic_with_hook::hf0478db2c66e7f22
   8:     0x7c354d192921 - std[de55bbf40c15c1d9]::panicking::begin_panic::<rustc_errors[31cbf59e29f13936]::ExplicitBug>::{closure#0}
   9:     0x7c354d186956 - std[de55bbf40c15c1d9]::sys::backtrace::__rust_end_short_backtrace::<std[de55bbf40c15c1d9]::panicking::begin_panic<rustc_errors[31cbf59e29f13936]::ExplicitBug>::{closure#0}, !>
  10:     0x7c354d1867db - std[de55bbf40c15c1d9]::panicking::begin_panic::<rustc_errors[31cbf59e29f13936]::ExplicitBug>
  11:     0x7c354d19ccf1 - <rustc_errors[31cbf59e29f13936]::diagnostic::BugAbort as rustc_errors[31cbf59e29f13936]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7c354d7482ec - <rustc_errors[31cbf59e29f13936]::DiagCtxtHandle>::span_bug::<rustc_span[98bd2c4b67b16de7]::span_encoding::Span, alloc[63d4616c10cc4540]::string::String>
  13:     0x7c354d7df1d7 - rustc_middle[71ebc2cfed4e8fd4]::util::bug::opt_span_bug_fmt::<rustc_span[98bd2c4b67b16de7]::span_encoding::Span>::{closure#0}
  14:     0x7c354d7ba21a - rustc_middle[71ebc2cfed4e8fd4]::ty::context::tls::with_opt::<rustc_middle[71ebc2cfed4e8fd4]::util::bug::opt_span_bug_fmt<rustc_span[98bd2c4b67b16de7]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  15:     0x7c354d7ba08b - rustc_middle[71ebc2cfed4e8fd4]::ty::context::tls::with_context_opt::<rustc_middle[71ebc2cfed4e8fd4]::ty::context::tls::with_opt<rustc_middle[71ebc2cfed4e8fd4]::util::bug::opt_span_bug_fmt<rustc_span[98bd2c4b67b16de7]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  16:     0x7c354b8ed237 - rustc_middle[71ebc2cfed4e8fd4]::util::bug::span_bug_fmt::<rustc_span[98bd2c4b67b16de7]::span_encoding::Span>
  17:     0x7c354eb62ed6 - <dyn rustc_hir_analysis[ded1f67b4756a5c]::hir_ty_lowering::HirTyLowerer>::lower_const_arg
  18:     0x7c354eb53bf8 - <dyn rustc_hir_analysis[ded1f67b4756a5c]::hir_ty_lowering::HirTyLowerer>::lower_ty
  19:     0x7c354eb3c04b - rustc_hir_analysis[ded1f67b4756a5c]::collect::type_of::type_of
  20:     0x7c354eb3b678 - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::type_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>>
  21:     0x7c354eb359ef - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_query_system[5b8097dc30659efa]::query::caches::DefIdCache<rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, false>
  22:     0x7c354eb3559f - rustc_query_impl[10518d27c996caef]::query_impl::type_of::get_query_non_incr::__rust_end_short_backtrace
  23:     0x7c354e9d1591 - rustc_middle[71ebc2cfed4e8fd4]::ty::trait_def::trait_impls_of_provider
  24:     0x7c354e9d2ba3 - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::trait_impls_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>>
  25:     0x7c354eb359ef - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_query_system[5b8097dc30659efa]::query::caches::DefIdCache<rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, false>
  26:     0x7c354eb2c43b - rustc_query_impl[10518d27c996caef]::query_impl::trait_impls_of::get_query_non_incr::__rust_end_short_backtrace
  27:     0x7c354f4bd0ec - <rustc_trait_selection[585b92a45c9def05]::traits::select::SelectionContext>::candidate_from_obligation::{closure#0}::{closure#0}
  28:     0x7c354f0cc75b - <rustc_trait_selection[585b92a45c9def05]::traits::select::SelectionContext>::poly_select::{closure#0}
  29:     0x7c354f22cfd8 - <rustc_trait_selection[585b92a45c9def05]::traits::fulfill::FulfillProcessor as rustc_data_structures[796c5d692efe04c0]::obligation_forest::ObligationProcessor>::process_obligation
  30:     0x7c354e807648 - <rustc_data_structures[796c5d692efe04c0]::obligation_forest::ObligationForest<rustc_trait_selection[585b92a45c9def05]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[585b92a45c9def05]::traits::fulfill::FulfillProcessor>
  31:     0x7c354ef92467 - <rustc_trait_selection[585b92a45c9def05]::traits::fulfill::FulfillmentContext<rustc_trait_selection[585b92a45c9def05]::traits::FulfillmentError> as rustc_infer[297106f8a53538f8]::traits::engine::TraitEngine<rustc_trait_selection[585b92a45c9def05]::traits::FulfillmentError>>::select_all_or_error
  32:     0x7c354f1159a6 - rustc_hir_analysis[ded1f67b4756a5c]::check::wfcheck::check_trait
  33:     0x7c354f103738 - rustc_hir_analysis[ded1f67b4756a5c]::check::wfcheck::check_well_formed
  34:     0x7c354f10186b - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7c354f101114 - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_data_structures[796c5d692efe04c0]::vec_cache::VecCache<rustc_span[98bd2c4b67b16de7]::def_id::LocalDefId, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[5b8097dc30659efa]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, false>
  36:     0x7c354f100c03 - rustc_query_impl[10518d27c996caef]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7c354f0fd065 - rustc_hir_analysis[ded1f67b4756a5c]::check::wfcheck::check_mod_type_wf
  38:     0x7c354f0fce5d - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::check_mod_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 1usize]>>
  39:     0x7c354f853c59 - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_query_system[5b8097dc30659efa]::query::caches::DefaultCache<rustc_span[98bd2c4b67b16de7]::def_id::LocalModDefId, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, false>
  40:     0x7c354f8539ca - rustc_query_impl[10518d27c996caef]::query_impl::check_mod_type_wf::get_query_non_incr::__rust_end_short_backtrace
  41:     0x7c354ea42e72 - rustc_hir_analysis[ded1f67b4756a5c]::check_crate
  42:     0x7c354f1fed34 - rustc_interface[dc0dcaed68c46eda]::passes::run_required_analyses
  43:     0x7c354f6e2bde - rustc_interface[dc0dcaed68c46eda]::passes::analysis
  44:     0x7c354f6e2bad - rustc_query_impl[10518d27c996caef]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[10518d27c996caef]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 0usize]>>
  45:     0x7c354f6e867d - rustc_query_system[5b8097dc30659efa]::query::plumbing::try_execute_query::<rustc_query_impl[10518d27c996caef]::DynamicConfig<rustc_query_system[5b8097dc30659efa]::query::caches::SingleCache<rustc_middle[71ebc2cfed4e8fd4]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[10518d27c996caef]::plumbing::QueryCtxt, false>
  46:     0x7c354f6e8378 - rustc_query_impl[10518d27c996caef]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  47:     0x7c354fa3bc00 - rustc_interface[dc0dcaed68c46eda]::passes::create_and_enter_global_ctxt::<core[2e306e03d5fcddd8]::option::Option<rustc_interface[dc0dcaed68c46eda]::queries::Linker>, rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}::{closure#2}>::{closure#2}::{closure#0}
  48:     0x7c354f8d1a84 - rustc_interface[dc0dcaed68c46eda]::interface::run_compiler::<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}
  49:     0x7c354f70f528 - std[de55bbf40c15c1d9]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_with_globals<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_pool_with_globals<rustc_interface[dc0dcaed68c46eda]::interface::run_compiler<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  50:     0x7c354f70f974 - <<std[de55bbf40c15c1d9]::thread::Builder>::spawn_unchecked_<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_with_globals<rustc_interface[dc0dcaed68c46eda]::util::run_in_thread_pool_with_globals<rustc_interface[dc0dcaed68c46eda]::interface::run_compiler<(), rustc_driver_impl[60c1a2efe706eb75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[2e306e03d5fcddd8]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  51:     0x7c354f710d77 - std::sys::pal::unix::thread::Thread::new::thread_start::ha9b262a03fd58cd3
  52:     0x7c35496a3708 - <unknown>
  53:     0x7c3549727aac - <unknown>
  54:                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: please attach the file at `/home/lw/Work/rust/nfuzz2/rustc-ice-2025-04-25T00_39_29-1692280.txt` to your bug report

note: compiler flags: -C opt-level=3 -Z no-codegen -Z mir-opt-level=4 -Z validate-mir --crate-type lib

query stack during panic:
#0 [type_of] computing type of `<impl at results/2.rs:4:1: 4:44>`
#1 [trait_impls_of] finding trait impls of `T`
#2 [check_well_formed] checking that `T` is well-formed
#3 [check_mod_type_wf] checking that types are well-formed in top-level module
#4 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 1 previous error; 1 warning emitted


Please do teach me if I've done anything wrong :)

@wychlw wychlw 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 Apr 25, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 25, 2025
@jieyouxu jieyouxu added F-generic_const_exprs `#![feature(generic_const_exprs)]` and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 25, 2025
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-generic_const_exprs `#![feature(generic_const_exprs)]` 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

3 participants