Skip to content

ICE cannot find !BoundConst { var: 1 } in param-env: ParamEnv { } #148629

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(with_negative_coherence)] trait ExampleTrait { type AssociatedType; } impl<T, const N: usize> ExampleTrait for [T; N] { } pub struct Happy<T> { , } impl<T> ExampleTrait for Happy<T> { } impl<T, const MYSIZE: usize> ExampleTrait for Happy<T> where [T; MYSIZE]: , <[T; MYSIZE] as T>::AssociatedType: Clone, [T; N]: , // 💣 <[T; MYSIZE] as ExampleTrait>::AssociatedType: Clone, { }

original:

trait ExampleTrait { type AssociatedType; } impl<T, const N: usize> ExampleTrait for [T; N] { type AssociatedType = T; } pub struct Happy<T> { arr: [Happy; MYSIZE], } impl<T> ExampleTrait for Happy<T> where [T; 10]: ExampleTrait, <[T; 10] as ExampleTrait>::AssociatedType: Clone, [T; 10]: ExampleTrait, <[T; 10] as ExampleTrait>::AssociatedType: Clone, { type AssociatedType = T; } pub const MYSIZE: usize = 10; pub struct Sad<T> { arr: [T; MYSIZE], } impl<T, const MYSIZE: usize> ExampleTrait for Happy<T> where [T; MYSIZE]: ExampleTrait, <[T; MYSIZE] as T>::AssociatedType: Clone, [T; N]: ExampleTrait, // 💣 <[T; MYSIZE] as ExampleTrait>::AssociatedType: Clone, { type AssociatedType = T; }

Version information

rustc 1.93.0-nightly (c90bcb957 2025-11-06) binary: rustc commit-hash: c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38 commit-date: 2025-11-06 host: x86_64-unknown-linux-gnu release: 1.93.0-nightly LLVM version: 21.1.3 

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(with_negative_coherence)

Program output

error: expected identifier, found `,` --> /tmp/icemaker_global_tempdir.zD8pQUt7PVI8/rustc_testrunner_tmpdir_reporting.UI4hL7vNdrSM/mvce.rs:11:5 | 10 | pub struct Happy<T> { | ----- while parsing this struct 11 | , | ^ expected identifier error[E0404]: expected trait, found type parameter `T` --> /tmp/icemaker_global_tempdir.zD8pQUt7PVI8/rustc_testrunner_tmpdir_reporting.UI4hL7vNdrSM/mvce.rs:26:21 | 23 | impl<T, const MYSIZE: usize> ExampleTrait for Happy<T> | - found this type parameter ... 26 | <[T; MYSIZE] as T>::AssociatedType: Clone, | ^ not a trait error[E0425]: cannot find value `N` in this scope --> /tmp/icemaker_global_tempdir.zD8pQUt7PVI8/rustc_testrunner_tmpdir_reporting.UI4hL7vNdrSM/mvce.rs:27:9 | 27 | [T; N]: , // 💣 | ^ not found in this scope error[E0601]: `main` function not found in crate `mvce` --> /tmp/icemaker_global_tempdir.zD8pQUt7PVI8/rustc_testrunner_tmpdir_reporting.UI4hL7vNdrSM/mvce.rs:31:2 | 31 | } | ^ consider adding a `main` function to `/tmp/icemaker_global_tempdir.zD8pQUt7PVI8/rustc_testrunner_tmpdir_reporting.UI4hL7vNdrSM/mvce.rs` thread 'rustc' (1257200) panicked at /rustc-dev/c90bcb9571b7aab0d8beaa2ce8a998ffaf079d38/compiler/rustc_type_ir/src/inherent.rs:580:13: cannot find `!BoundConst { var: 1 }` in param-env: ParamEnv { caller_bounds: [ Binder { value: TraitPredicate(<!0 as std::marker::Sized>, polarity:Positive), bound_vars: [] }, ], } stack backtrace: 0: 0x7f8944a5f223 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::hde21067283f7e82e 1: 0x7f8945201afc - core::fmt::write::h24186904251c31cb 2: 0x7f8944a13d93 - std::io::Write::write_fmt::h3ab9f1f4d8d19b72 3: 0x7f8944a253a2 - std::sys::backtrace::BacktraceLock::print::he038489aba5894a6 4: 0x7f8944a2b3f9 - std::panicking::default_hook::{{closure}}::h80a26d916c49679b 5: 0x7f8944a2af23 - std::panicking::default_hook::he2e9efee79b3dce9 6: 0x7f8943a20c91 - std[e95ebcffb71a5621]::panicking::update_hook::<alloc[6ba2be5df7d20276]::boxed::Box<rustc_driver_impl[8bc3447375e6b2d8]::install_ice_hook::{closure#1}>>::{closure#0} 7: 0x7f8944a2b81f - std::panicking::panic_with_hook::hf5648b7cec6bc73e 8: 0x7f8944a2b5da - std::panicking::panic_handler::{{closure}}::h1b2ed3864ba94359 9: 0x7f8944a254e9 - std::sys::backtrace::__rust_end_short_backtrace::hd0186b2b27f5aaa7 10: 0x7f8944a060dd - __rustc[f7dae8b92efe1d7a]::rust_begin_unwind 11: 0x7f8941a72000 - core::panicking::panic_fmt::hb5d6b83773432920 12: 0x7f8945dab661 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate> as rustc_type_ir[5e1db4e3d840b3d9]::search_graph::Delegate>::compute_goal::{closure#0} 13: 0x7f8945dc1257 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::evaluate_goal_raw 14: 0x7f8945db13bc - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::try_evaluate_added_goals 15: 0x7f8945f58750 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::evaluate_added_goals_and_make_canonical_response 16: 0x7f8945da60fb - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::assemble_impl_candidates::<rustc_type_ir[5e1db4e3d840b3d9]::predicate::TraitPredicate<rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::{closure#0} 17: 0x7f8945da17e6 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::compute_trait_goal 18: 0x7f8945daadff - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate> as rustc_type_ir[5e1db4e3d840b3d9]::search_graph::Delegate>::compute_goal::{closure#0} 19: 0x7f8945dc1257 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::evaluate_goal_raw 20: 0x7f8945db176d - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::try_evaluate_added_goals 21: 0x7f8945daa4f1 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate> as rustc_type_ir[5e1db4e3d840b3d9]::search_graph::Delegate>::compute_goal::{closure#0} 22: 0x7f8945dc1257 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::evaluate_goal_raw 23: 0x7f8945db13bc - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::try_evaluate_added_goals 24: 0x7f8945da2b7c - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::compute_trait_goal 25: 0x7f8945daa04b - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate> as rustc_type_ir[5e1db4e3d840b3d9]::search_graph::Delegate>::compute_goal::{closure#0} 26: 0x7f8945dc1257 - <rustc_next_trait_solver[80d5b8e7e915485e]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[47719877e32dbd7c]::solve::delegate::SolverDelegate, rustc_middle[9ce76f953d15e2f6]::ty::context::TyCtxt>>::evaluate_goal_raw 27: 0x7f8945db69c3 - <rustc_trait_selection[47719877e32dbd7c]::solve::fulfill::FulfillmentCtxt<rustc_infer[35191db886fd87e]::traits::engine::ScrubbedTraitError> as rustc_infer[35191db886fd87e]::traits::engine::TraitEngine<rustc_infer[35191db886fd87e]::traits::engine::ScrubbedTraitError>>::evaluate_obligations_error_on_ambiguity 28: 0x7f8944883e1e - rustc_trait_selection[47719877e32dbd7c]::traits::coherence::impl_intersection_has_negative_obligation 29: 0x7f8945dbeb0c - rustc_trait_selection[47719877e32dbd7c]::traits::coherence::overlap 30: 0x7f8941f51e62 - <rustc_middle[9ce76f953d15e2f6]::traits::specialization_graph::Children as rustc_trait_selection[47719877e32dbd7c]::traits::specialize::specialization_graph::ChildrenExt>::insert 31: 0x7f8945306e88 - <rustc_middle[9ce76f953d15e2f6]::traits::specialization_graph::Graph as rustc_trait_selection[47719877e32dbd7c]::traits::specialize::specialization_graph::GraphExt>::insert 32: 0x7f8945308368 - rustc_trait_selection[47719877e32dbd7c]::traits::specialize::specialization_graph_provider 33: 0x7f8945307d8d - rustc_query_impl[8ae232d5147ca84e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ae232d5147ca84e]::query_impl::specialization_graph_of::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 8usize]>> 34: 0x7f894521c806 - rustc_query_system[41b9c06994168e52]::query::plumbing::try_execute_query::<rustc_query_impl[8ae232d5147ca84e]::DynamicConfig<rustc_query_system[41b9c06994168e52]::query::caches::DefIdCache<rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 8usize]>>, false, false, false>, rustc_query_impl[8ae232d5147ca84e]::plumbing::QueryCtxt, false> 35: 0x7f89459d1337 - rustc_query_impl[8ae232d5147ca84e]::query_impl::specialization_graph_of::get_query_non_incr::__rust_end_short_backtrace 36: 0x7f89459d1690 - rustc_hir_analysis[5cd9912eb92b8e51]::coherence::coherent_trait 37: 0x7f89459d135f - rustc_query_impl[8ae232d5147ca84e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ae232d5147ca84e]::query_impl::coherent_trait::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 1usize]>> 38: 0x7f8945a3c523 - rustc_query_system[41b9c06994168e52]::query::plumbing::try_execute_query::<rustc_query_impl[8ae232d5147ca84e]::DynamicConfig<rustc_query_system[41b9c06994168e52]::query::caches::DefIdCache<rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8ae232d5147ca84e]::plumbing::QueryCtxt, false> 39: 0x7f8945a3b5a4 - rustc_query_impl[8ae232d5147ca84e]::query_impl::coherent_trait::get_query_non_incr::__rust_end_short_backtrace 40: 0x7f89459de2fb - rustc_hir_analysis[5cd9912eb92b8e51]::check::check::check_item_type 41: 0x7f89459db39c - rustc_hir_analysis[5cd9912eb92b8e51]::check::wfcheck::check_well_formed 42: 0x7f89459db375 - rustc_query_impl[8ae232d5147ca84e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ae232d5147ca84e]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 1usize]>> 43: 0x7f89459dabec - rustc_query_system[41b9c06994168e52]::query::plumbing::try_execute_query::<rustc_query_impl[8ae232d5147ca84e]::DynamicConfig<rustc_data_structures[de67cf687b97999a]::vec_cache::VecCache<rustc_span[28eed06c8d001cb1]::def_id::LocalDefId, rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[41b9c06994168e52]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[8ae232d5147ca84e]::plumbing::QueryCtxt, false> 44: 0x7f89459da702 - rustc_query_impl[8ae232d5147ca84e]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace 45: 0x7f89459d7c70 - rustc_hir_analysis[5cd9912eb92b8e51]::check::wfcheck::check_type_wf 46: 0x7f89459d7b5d - rustc_query_impl[8ae232d5147ca84e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ae232d5147ca84e]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 1usize]>> 47: 0x7f8946296948 - rustc_query_system[41b9c06994168e52]::query::plumbing::try_execute_query::<rustc_query_impl[8ae232d5147ca84e]::DynamicConfig<rustc_query_system[41b9c06994168e52]::query::caches::SingleCache<rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[8ae232d5147ca84e]::plumbing::QueryCtxt, false> 48: 0x7f894629670e - rustc_query_impl[8ae232d5147ca84e]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace 49: 0x7f894553acba - rustc_hir_analysis[5cd9912eb92b8e51]::check_crate 50: 0x7f8945521ab0 - rustc_interface[d5ff205a9ab97820]::passes::analysis 51: 0x7f8945521773 - rustc_query_impl[8ae232d5147ca84e]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[8ae232d5147ca84e]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 0usize]>> 52: 0x7f894629d360 - rustc_query_system[41b9c06994168e52]::query::plumbing::try_execute_query::<rustc_query_impl[8ae232d5147ca84e]::DynamicConfig<rustc_query_system[41b9c06994168e52]::query::caches::SingleCache<rustc_middle[9ce76f953d15e2f6]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[8ae232d5147ca84e]::plumbing::QueryCtxt, false> 53: 0x7f894629cfb6 - rustc_query_impl[8ae232d5147ca84e]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace 54: 0x7f894655a00a - <rustc_interface[d5ff205a9ab97820]::passes::create_and_enter_global_ctxt<core[a4c7c2348b0f0abe]::option::Option<rustc_interface[d5ff205a9ab97820]::queries::Linker>, rustc_driver_impl[8bc3447375e6b2d8]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[a4c7c2348b0f0abe]::ops::function::FnOnce<(&rustc_session[84c9ddeb8f325268]::session::Session, rustc_middle[9ce76f953d15e2f6]::ty::context::CurrentGcx, alloc[6ba2be5df7d20276]::sync::Arc<rustc_data_structures[de67cf687b97999a]::jobserver::Proxy>, &std[e95ebcffb71a5621]::sync::once_lock::OnceLock<rustc_middle[9ce76f953d15e2f6]::ty::context::GlobalCtxt>, &rustc_data_structures[de67cf687b97999a]::sync::worker_local::WorkerLocal<rustc_middle[9ce76f953d15e2f6]::arena::Arena>, &rustc_data_structures[de67cf687b97999a]::sync::worker_local::WorkerLocal<rustc_hir[1534e3459f232f80]::Arena>, rustc_driver_impl[8bc3447375e6b2d8]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0} 55: 0x7f89463fbfe9 - rustc_interface[d5ff205a9ab97820]::interface::run_compiler::<(), rustc_driver_impl[8bc3447375e6b2d8]::run_compiler::{closure#0}>::{closure#1} 56: 0x7f8946090e3c - std[e95ebcffb71a5621]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[d5ff205a9ab97820]::util::run_in_thread_with_globals<rustc_interface[d5ff205a9ab97820]::util::run_in_thread_pool_with_globals<rustc_interface[d5ff205a9ab97820]::interface::run_compiler<(), rustc_driver_impl[8bc3447375e6b2d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()> 57: 0x7f8946090b20 - <<std[e95ebcffb71a5621]::thread::Builder>::spawn_unchecked_<rustc_interface[d5ff205a9ab97820]::util::run_in_thread_with_globals<rustc_interface[d5ff205a9ab97820]::util::run_in_thread_pool_with_globals<rustc_interface[d5ff205a9ab97820]::interface::run_compiler<(), rustc_driver_impl[8bc3447375e6b2d8]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[a4c7c2348b0f0abe]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0} 58: 0x7f8946095daf - std::sys::thread::unix::Thread::new::thread_start::hb3dc6483caa1b987 59: 0x7f893fa969cb - <unknown> 60: 0x7f893fb1aa0c - <unknown> 61: 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: rustc 1.93.0-nightly (c90bcb957 2025-11-06) running on x86_64-unknown-linux-gnu note: compiler flags: -Z crate-attr=feature(with_negative_coherence) -Z dump-mir-dir=dir query stack during panic: #0 [specialization_graph_of] building specialization graph of trait `ExampleTrait` #1 [coherent_trait] coherence checking all impls of trait `ExampleTrait` #2 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.zD8pQUt7PVI8/rustc_testrunner_tmpdir_reporting.UI4hL7vNdrSM/mvce.rs:5:1: 5:48>` is well-formed #3 [check_type_wf] checking that types are well-formed #4 [analysis] running analysis passes on crate `mvce` end of query stack error[E0392]: type parameter `T` is never used --> /tmp/icemaker_global_tempdir.zD8pQUt7PVI8/rustc_testrunner_tmpdir_reporting.UI4hL7vNdrSM/mvce.rs:10:18 | 10 | pub struct Happy<T> { | ^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead error: aborting due to 5 previous errors Some errors have detailed explanations: E0392, E0404, E0425, E0601. For more information about an error, try `rustc --explain E0392`. 

@rustbot label +F-with_negative_coherence

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-with_negative_coherence`#![feature(with_negative_coherence)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions