Skip to content

ICE: cannot find .. in param-env: ParamEnv #148096

Description

@matthiaskrgr

unlike #143117, this one does neither require any feature gates nor compiler flags, it also repros on stable already

auto-reduced (treereduce-rust):

impl<
        const N: usize = {
            static || {
                Foo([0; X]);
            }
        },
    > PartialEq for True
{
}

original:

impl<
        const N: usize = {
            static || {
                Foo([0; X]);
            }
        },
    > PartialEq for True
{
}

Version information

rustc 1.92.0-nightly (f43597208 2025-10-24)
binary: rustc
commit-hash: f435972085b697a1ece8ee6a1ac76efff8d1df7b
commit-date: 2025-10-24
host: x86_64-unknown-linux-gnu
release: 1.92.0-nightly
LLVM version: 21.1.3

Possibly related line of code:

// `Option<Ty<'tcx>>` instead of `Ty<'tcx>`; however, this is generally
// considered to be a bandaid solution, since it hides more important
// underlying issues with how we construct generics and predicates of
// items. It's advised to fix the underlying issue rather than trying
// to modify this function.
let ty = candidates.next().unwrap_or_else(|| {
bug!("cannot find `{self:?}` in param-env: {env:#?}");
});
assert!(
candidates.next().is_none(),
"did not expect duplicate `ConstParamHasTy` for `{self:?}` in param-env: {env:#?}"
);
ty

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zincremental-verify-ich=yes -Cincremental=<dir> -Cdebuginfo=2 -Clink-dead-code=true -Zvalidate-mir -Zquery-dep-graph -Zthreads=4 --edition=2024

Program output

error[E0412]: cannot find type `True` in this scope
 --> /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:7:21
  |
7 |     > PartialEq for True
  |                     ^^^^ not found in this scope
  |
help: you may want to use a bool value instead
  |
7 -     > PartialEq for True
7 +     > PartialEq for true
  |

error[E0425]: cannot find value `X` in this scope
 --> /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:4:25
  |
2 |         const N: usize = {
  |               - similarly named const parameter `N` defined here
3 |             static || {
4 |                 Foo([0; X]);
  |                         ^ help: a const parameter with a similar name exists: `N`

error[E0658]: coroutine syntax is experimental
 --> /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:3:13
  |
3 |             static || {
  |             ^^^^^^
  |
  = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information
  = help: add `#![feature(coroutines)]` to the crate attributes to enable
  = note: this compiler was built on 2025-10-24; consider upgrading it if it is out of date

error[E0697]: closures cannot be static
 --> /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:3:13
  |
3 |             static || {
  |             ^^^^^^^^^

error[E0601]: `main` function not found in crate `mvce`
 --> /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:9:2
  |
9 | }
  |  ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs`

error: defaults for generic parameters are not allowed here
 --> /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:2:9
  |
2 | /         const N: usize = {
3 | |             static || {
4 | |                 Foo([0; X]);
5 | |             }
6 | |         },
  | |_________^

error: internal compiler error: compiler/rustc_middle/src/ty/sty.rs:373:13: cannot find `N/#0` in param-env: ParamEnv {
                                    caller_bounds: [],
                                }


thread 'rustc' (4015949) panicked at compiler/rustc_middle/src/ty/sty.rs:373:13:
Box<dyn Any>
stack backtrace:
   0:     0x7f486b634073 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h492c738ad49cea7d
   1:     0x7f486be01b98 - core::fmt::write::h1c21b4db123ae31c
   2:     0x7f486b5e8403 - std::io::Write::write_fmt::h78003e47d8f6c72e
   3:     0x7f486b5f9bf2 - std::sys::backtrace::BacktraceLock::print::h0d646c4d1cbf366e
   4:     0x7f486b5ffcc9 - std::panicking::default_hook::{{closure}}::h274ab31bbd3c2851
   5:     0x7f486b5ff7f3 - std::panicking::default_hook::he590f8320f1e009e
   6:     0x7f486a600611 - std[3e186dc2068ac4b9]::panicking::update_hook::<alloc[47fc8f5871530046]::boxed::Box<rustc_driver_impl[b652d2bf07caa0d8]::install_ice_hook::{closure#1}>>::{closure#0}
   7:     0x7f486b6000ef - std::panicking::panic_with_hook::hc0910476a8aaf08a
   8:     0x7f486a639e61 - std[3e186dc2068ac4b9]::panicking::begin_panic::<rustc_errors[345ffcadd731d51f]::ExplicitBug>::{closure#0}
   9:     0x7f486a62e056 - std[3e186dc2068ac4b9]::sys::backtrace::__rust_end_short_backtrace::<std[3e186dc2068ac4b9]::panicking::begin_panic<rustc_errors[345ffcadd731d51f]::ExplicitBug>::{closure#0}, !>
  10:     0x7f486a62b939 - std[3e186dc2068ac4b9]::panicking::begin_panic::<rustc_errors[345ffcadd731d51f]::ExplicitBug>
  11:     0x7f486a6459d1 - <rustc_errors[345ffcadd731d51f]::diagnostic::BugAbort as rustc_errors[345ffcadd731d51f]::diagnostic::EmissionGuarantee>::emit_producing_guarantee
  12:     0x7f486abdd4ea - rustc_middle[df80570e3f8f0476]::util::bug::opt_span_bug_fmt::<rustc_span[b6aef8613cdfc213]::span_encoding::Span>::{closure#0}
  13:     0x7f486abdd7ca - rustc_middle[df80570e3f8f0476]::ty::context::tls::with_opt::<rustc_middle[df80570e3f8f0476]::util::bug::opt_span_bug_fmt<rustc_span[b6aef8613cdfc213]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  14:     0x7f486abce53b - rustc_middle[df80570e3f8f0476]::ty::context::tls::with_context_opt::<rustc_middle[df80570e3f8f0476]::ty::context::tls::with_opt<rustc_middle[df80570e3f8f0476]::util::bug::opt_span_bug_fmt<rustc_span[b6aef8613cdfc213]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  15:     0x7f4868946320 - rustc_middle[df80570e3f8f0476]::util::bug::bug_fmt
  16:     0x7f486d913767 - <rustc_middle[df80570e3f8f0476]::ty::sty::ParamConst>::find_const_ty_from_env.cold
  17:     0x7f486c6e8e75 - <rustc_trait_selection[cf51c7a433a87fce]::traits::fulfill::FulfillProcessor as rustc_data_structures[9e234764dc4c351e]::obligation_forest::ObligationProcessor>::process_obligation
  18:     0x7f486be04e09 - <rustc_data_structures[9e234764dc4c351e]::obligation_forest::ObligationForest<rustc_trait_selection[cf51c7a433a87fce]::traits::fulfill::PendingPredicateObligation>>::process_obligations::<rustc_trait_selection[cf51c7a433a87fce]::traits::fulfill::FulfillProcessor>
  19:     0x7f486cc1a6d9 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x7f486cc25059 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  21:     0x7f486c0acdb7 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_call
  22:     0x7f486cc1a994 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  23:     0x7f486cc15903 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_block
  24:     0x7f486cc1b097 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  25:     0x7f486cc0db5a - rustc_hir_typeck[ca3afe1245f8583a]::check::check_fn
  26:     0x7f486c659787 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_closure
  27:     0x7f486cc2231d - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  28:     0x7f486cc14b22 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_block
  29:     0x7f486cc1b097 - <rustc_hir_typeck[ca3afe1245f8583a]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  30:     0x7f486c8faf7e - rustc_hir_typeck[ca3afe1245f8583a]::typeck_with_inspect::{closure#0}
  31:     0x7f486c8f6b30 - rustc_query_impl[ce892b7de41d33cc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ce892b7de41d33cc]::query_impl::typeck::dynamic_query::{closure#2}::{closure#0}, rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 8usize]>>
  32:     0x7f486bef472c - rustc_query_system[c36681704e76fc2e]::query::plumbing::try_execute_query::<rustc_query_impl[ce892b7de41d33cc]::DynamicConfig<rustc_data_structures[9e234764dc4c351e]::vec_cache::VecCache<rustc_span[b6aef8613cdfc213]::def_id::LocalDefId, rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[c36681704e76fc2e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[ce892b7de41d33cc]::plumbing::QueryCtxt, true>
  33:     0x7f486bef1b35 - rustc_query_impl[ce892b7de41d33cc]::query_impl::typeck::get_query_incr::__rust_end_short_backtrace
  34:     0x7f486c8d6ff3 - rustc_query_impl[ce892b7de41d33cc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ce892b7de41d33cc]::query_impl::used_trait_imports::dynamic_query::{closure#2}::{closure#0}, rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 8usize]>>
  35:     0x7f486bef472c - rustc_query_system[c36681704e76fc2e]::query::plumbing::try_execute_query::<rustc_query_impl[ce892b7de41d33cc]::DynamicConfig<rustc_data_structures[9e234764dc4c351e]::vec_cache::VecCache<rustc_span[b6aef8613cdfc213]::def_id::LocalDefId, rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 8usize]>, rustc_query_system[c36681704e76fc2e]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[ce892b7de41d33cc]::plumbing::QueryCtxt, true>
  36:     0x7f486bef3c83 - rustc_query_impl[ce892b7de41d33cc]::query_impl::used_trait_imports::get_query_incr::__rust_end_short_backtrace
  37:     0x7f486c8d54cd - rustc_hir_analysis[83592e86f71d95cd]::check_unused::check_unused_traits
  38:     0x7f486c8d53cd - rustc_query_impl[ce892b7de41d33cc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ce892b7de41d33cc]::query_impl::check_unused_traits::dynamic_query::{closure#2}::{closure#0}, rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 0usize]>>
  39:     0x7f486d208e78 - rustc_query_system[c36681704e76fc2e]::query::plumbing::try_execute_query::<rustc_query_impl[ce892b7de41d33cc]::DynamicConfig<rustc_query_system[c36681704e76fc2e]::query::caches::SingleCache<rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ce892b7de41d33cc]::plumbing::QueryCtxt, true>
  40:     0x7f486d208723 - rustc_query_impl[ce892b7de41d33cc]::query_impl::check_unused_traits::get_query_incr::__rust_end_short_backtrace
  41:     0x7f486c8a590c - rustc_hir_analysis[83592e86f71d95cd]::check_crate
  42:     0x7f486c8cf770 - rustc_interface[10f842ee2745836b]::passes::analysis
  43:     0x7f486c8cf435 - rustc_query_impl[ce892b7de41d33cc]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[ce892b7de41d33cc]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 0usize]>>
  44:     0x7f486d208fc8 - rustc_query_system[c36681704e76fc2e]::query::plumbing::try_execute_query::<rustc_query_impl[ce892b7de41d33cc]::DynamicConfig<rustc_query_system[c36681704e76fc2e]::query::caches::SingleCache<rustc_middle[df80570e3f8f0476]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[ce892b7de41d33cc]::plumbing::QueryCtxt, true>
  45:     0x7f486d20883f - rustc_query_impl[ce892b7de41d33cc]::query_impl::analysis::get_query_incr::__rust_end_short_backtrace
  46:     0x7f486d13ec8a - <rustc_interface[10f842ee2745836b]::passes::create_and_enter_global_ctxt<core[e8997f4232dfd718]::option::Option<rustc_interface[10f842ee2745836b]::queries::Linker>, rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[e8997f4232dfd718]::ops::function::FnOnce<(&rustc_session[4dec040bcdb04b8e]::session::Session, rustc_middle[df80570e3f8f0476]::ty::context::CurrentGcx, alloc[47fc8f5871530046]::sync::Arc<rustc_data_structures[9e234764dc4c351e]::jobserver::Proxy>, &std[3e186dc2068ac4b9]::sync::once_lock::OnceLock<rustc_middle[df80570e3f8f0476]::ty::context::GlobalCtxt>, &rustc_data_structures[9e234764dc4c351e]::sync::worker_local::WorkerLocal<rustc_middle[df80570e3f8f0476]::arena::Arena>, &rustc_data_structures[9e234764dc4c351e]::sync::worker_local::WorkerLocal<rustc_hir[739a0293ab2ba12c]::Arena>, rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  47:     0x7f486cfb37e2 - rustc_interface[10f842ee2745836b]::interface::run_compiler::<(), rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}>::{closure#1}
  48:     0x7f486a618734 - <rustc_thread_pool[7fc909dca122daad]::job::StackJob<rustc_thread_pool[7fc909dca122daad]::latch::LatchRef<rustc_thread_pool[7fc909dca122daad]::latch::LockLatch>, <rustc_thread_pool[7fc909dca122daad]::registry::Registry>::in_worker_cold<<rustc_thread_pool[7fc909dca122daad]::thread_pool::ThreadPool>::install<rustc_interface[10f842ee2745836b]::util::run_in_thread_pool_with_globals<rustc_interface[10f842ee2745836b]::interface::run_compiler<(), rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}::{closure#0}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> as rustc_thread_pool[7fc909dca122daad]::job::Job>::execute
  49:     0x7f486b30bb1f - <rustc_thread_pool[7fc909dca122daad]::registry::WorkerThread>::wait_or_steal_until_cold
  50:     0x7f486b30a5c1 - <rustc_thread_pool[7fc909dca122daad]::registry::ThreadBuilder>::run
  51:     0x7f486a5f803d - std[3e186dc2068ac4b9]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_thread_pool[7fc909dca122daad]::ThreadPoolBuilder>::build_scoped<rustc_interface[10f842ee2745836b]::util::run_in_thread_pool_with_globals<rustc_interface[10f842ee2745836b]::interface::run_compiler<(), rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[10f842ee2745836b]::util::run_in_thread_pool_with_globals<rustc_interface[10f842ee2745836b]::interface::run_compiler<(), rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  52:     0x7f486a603632 - <<std[3e186dc2068ac4b9]::thread::Builder>::spawn_unchecked_<<rustc_thread_pool[7fc909dca122daad]::ThreadPoolBuilder>::build_scoped<rustc_interface[10f842ee2745836b]::util::run_in_thread_pool_with_globals<rustc_interface[10f842ee2745836b]::interface::run_compiler<(), rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[10f842ee2745836b]::util::run_in_thread_pool_with_globals<rustc_interface[10f842ee2745836b]::interface::run_compiler<(), rustc_driver_impl[b652d2bf07caa0d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core[e8997f4232dfd718]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  53:     0x7f486cbbf02f - std::sys::thread::unix::Thread::new::thread_start::h69c86f976e686da7
  54:     0x7f48666969cb - <unknown>
  55:     0x7f486671aa0c - <unknown>
  56:                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.92.0-nightly (f43597208 2025-10-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z incremental-verify-ich=yes -C incremental=[REDACTED] -C debuginfo=2 -C link-dead-code=true -Z validate-mir -Z query-dep-graph -Z threads=4

query stack during panic:
#0 [typeck] type-checking `<impl at /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:1:1: 7:25>::{constant#0}`
#1 [used_trait_imports] finding used_trait_imports `<impl at /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:1:1: 7:25>::{constant#0}`
#2 [check_unused_traits] checking unused trait imports in crate
#3 [analysis] running analysis passes on this crate
end of query stack
error[E0425]: cannot find function, tuple struct or tuple variant `Foo` in this scope
 --> /tmp/icemaker_global_tempdir.20BLeJTxFmM8/rustc_testrunner_tmpdir_reporting.ttxZjEyNw73B/mvce.rs:4:17
  |
4 |                 Foo([0; X]);
  |                 ^^^ not found in this scope

error: aborting due to 8 previous errors

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-genericsArea: const generics (parameters and arguments)C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions