rust-lang / rust-lang/rust

[ICE]: `var types encountered in structurally_relate_consts: ?1c ?1c`

Open
#157,938 3 comments 0 reactions 1 assignee View on GitHub

@bit-aloo is already working on this.

Since Jun 18, 2026.

C-bug F-generic_const_exprs I-ICE needs-triage T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

original:

#![feature(generic_const_exprs)]
trait IsZero<const N: u8> {}
impl<const N: u8> IsZero<N> for () {}
trait Foobar<const N: u8> {}
impl<const N: u8> Foobar<N> for () where (): IsZero<N> {}
impl<const N: u8>
    Foobar<
        {
            {
                N
            }
        },
    > for ()
{
}

fn main() {}

Version information

rustc 1.98.0-nightly (42d7d5292 2026-06-15)
binary: rustc
commit-hash: 42d7d5292025a31aaf02100ae5bd664aca66bbbb
commit-date: 2026-06-15
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.7

Possibly related line of code:
https://github.com/rust-lang/rust/blob/42d7d5292025a31aaf02100ae5bd664aca66bbbb/compiler/rustc_type_ir/src/relate.rs#L576-L588

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc file.rs

Program output

warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.yqoNYHxs2mJh/rustc_testrunner_tmpdir_reporting.QC5ogv3zZwCi/mvce.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


thread 'rustc' (2051033) panicked at /rustc-dev/42d7d5292025a31aaf02100ae5bd664aca66bbbb/compiler/rustc_type_ir/src/relate.rs:582:13:
var types encountered in structurally_relate_consts: ?1c ?1c
stack backtrace:
   0:     0x7f9bf84dc009 - <<std[f97f41f4b941f83d]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[d89867bba8befc45]::fmt::Display>::fmt
   1:     0x7f9bf8c0ec1e - core[d89867bba8befc45]::fmt::write
   2:     0x7f9bf84f2436 - <std[f97f41f4b941f83d]::sys::stdio::unix::Stderr as std[f97f41f4b941f83d]::io::Write>::write_fmt
   3:     0x7f9bf84b12fe - std[f97f41f4b941f83d]::panicking::default_hook::{closure#0}
   4:     0x7f9bf84cecf3 - std[f97f41f4b941f83d]::panicking::default_hook
   5:     0x7f9bf72a978c - std[f97f41f4b941f83d]::panicking::update_hook::<alloc[4ab400356fefd9c6]::boxed::Box<rustc_driver_impl[94c2fdbf68adad86]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f9bf84cefd2 - std[f97f41f4b941f83d]::panicking::panic_with_hook
   7:     0x7f9bf84b13c2 - std[f97f41f4b941f83d]::panicking::panic_handler::{closure#0}
   8:     0x7f9bf84a80c9 - std[f97f41f4b941f83d]::sys::backtrace::__rust_end_short_backtrace::<std[f97f41f4b941f83d]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f9bf84b2e2d - __rustc[f60fb9840241c8c6]::rust_begin_unwind
  10:     0x7f9bf4f1f28c - core[d89867bba8befc45]::panicking::panic_fmt
  11:     0x7f9bfa86a2d2 - rustc_type_ir[e57b036b72c98f5]::relate::structurally_relate_consts::<rustc_middle[7183fb41e9311d8f]::ty::context::TyCtxt, rustc_type_ir[e57b036b72c98f5]::relate::solver_relating::SolverRelating<rustc_infer[222dbbcac456ce28]::infer::InferCtxt, rustc_middle[7183fb41e9311d8f]::ty::context::TyCtxt>>.cold
  12:     0x7f9bf9370882 - rustc_type_ir[e57b036b72c98f5]::relate::combine::super_combine_consts::<rustc_infer[222dbbcac456ce28]::infer::InferCtxt, rustc_middle[7183fb41e9311d8f]::ty::context::TyCtxt, rustc_type_ir[e57b036b72c98f5]::relate::solver_relating::SolverRelating<rustc_infer[222dbbcac456ce28]::infer::InferCtxt, rustc_middle[7183fb41e9311d8f]::ty::context::TyCtxt>>
  13:     0x7f9bf936d3f9 - rustc_next_trait_solver[cdf54091203d2f39]::canonical::unify_query_var_values::<rustc_trait_selection[a78496944b282a58]::solve::delegate::SolverDelegate, rustc_middle[7183fb41e9311d8f]::ty::context::TyCtxt>
  14:     0x7f9bf9e7e500 - rustc_next_trait_solver[cdf54091203d2f39]::canonical::instantiate_canonical_state::<rustc_trait_selection[a78496944b282a58]::solve::delegate::SolverDelegate, rustc_middle[7183fb41e9311d8f]::ty::context::TyCtxt, ()>
  15:     0x7f9bf9e7f018 - <rustc_trait_selection[a78496944b282a58]::solve::inspect::analyse::InspectCandidate>::instantiate_nested_goals
  16:     0x7f9bf9e83270 - <rustc_trait_selection[a78496944b282a58]::solve::fulfill::derive_errors::BestObligation as rustc_trait_selection[a78496944b282a58]::solve::inspect::analyse::ProofTreeVisitor>::visit_goal
  17:     0x7f9bf9e82ef4 - <rustc_infer[222dbbcac456ce28]::infer::InferCtxt as rustc_trait_selection[a78496944b282a58]::solve::inspect::analyse::InferCtxtProofTreeExt>::visit_proof_tree_at_depth::<rustc_trait_selection[a78496944b282a58]::solve::fulfill::derive_errors::BestObligation>
  18:     0x7f9bf97ba738 - rustc_trait_selection[a78496944b282a58]::solve::fulfill::derive_errors::find_best_leaf_obligation
  19:     0x7f9bf97ba0ec - <rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError as rustc_infer[222dbbcac456ce28]::traits::engine::FromSolverError<rustc_trait_selection[a78496944b282a58]::solve::fulfill::NextSolverError>>::from_solver_error
  20:     0x7f9bf972ce82 - <core[d89867bba8befc45]::iter::adapters::map::Map<core[d89867bba8befc45]::iter::adapters::chain::Chain<core[d89867bba8befc45]::iter::adapters::map::Map<thin_vec[e9bb81cf893152c1]::Drain<(rustc_infer[222dbbcac456ce28]::traits::Obligation<rustc_middle[7183fb41e9311d8f]::ty::predicate::Predicate>, core[d89867bba8befc45]::option::Option<rustc_next_trait_solver[cdf54091203d2f39]::solve::GoalStalledOn<rustc_middle[7183fb41e9311d8f]::ty::context::TyCtxt>>)>, <rustc_trait_selection[a78496944b282a58]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError> as rustc_infer[222dbbcac456ce28]::traits::engine::TraitEngine<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError>>::collect_remaining_errors::{closure#0}>, core[d89867bba8befc45]::iter::adapters::map::Map<alloc[4ab400356fefd9c6]::vec::drain::Drain<rustc_infer[222dbbcac456ce28]::traits::Obligation<rustc_middle[7183fb41e9311d8f]::ty::predicate::Predicate>>, <rustc_trait_selection[a78496944b282a58]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError> as rustc_infer[222dbbcac456ce28]::traits::engine::TraitEngine<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError>>::collect_remaining_errors::{closure#1}>>, <rustc_trait_selection[a78496944b282a58]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError> as rustc_infer[222dbbcac456ce28]::traits::engine::TraitEngine<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError>>::collect_remaining_errors::{closure#2}> as core[d89867bba8befc45]::iter::traits::iterator::Iterator>::next
  21:     0x7f9bf972cc99 - <rustc_trait_selection[a78496944b282a58]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError> as rustc_infer[222dbbcac456ce28]::traits::engine::TraitEngine<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError>>::collect_remaining_errors
  22:     0x7f9bf968c879 - <rustc_trait_selection[a78496944b282a58]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError> as rustc_infer[222dbbcac456ce28]::traits::engine::TraitEngine<rustc_trait_selection[a78496944b282a58]::traits::FulfillmentError>>::evaluate_obligations_error_on_ambiguity
  23:     0x7f9bf967d88a - rustc_trait_selection[a78496944b282a58]::traits::coherence::overlap
  24:     0x7f9bf4cdb407 - <rustc_middle[7183fb41e9311d8f]::traits::specialization_graph::Children as rustc_trait_selection[a78496944b282a58]::traits::specialize::specialization_graph::ChildrenExt>::insert
  25:     0x7f9bf8c80ef7 - <rustc_middle[7183fb41e9311d8f]::traits::specialization_graph::Graph as rustc_trait_selection[a78496944b282a58]::traits::specialize::specialization_graph::GraphExt>::insert
  26:     0x7f9bf8c822db - rustc_trait_selection[a78496944b282a58]::traits::specialize::specialization_graph_provider
  27:     0x7f9bf8f25c77 - rustc_query_impl[ba2049ed27b9e923]::execution::try_execute_query::<rustc_middle[7183fb41e9311d8f]::query::caches::DefIdCache<rustc_middle[7183fb41e9311d8f]::query::erase::ErasedData<[u8; 8usize]>>, true>
  28:     0x7f9bf9c60f15 - rustc_query_impl[ba2049ed27b9e923]::query_impl::specialization_graph_of::execute_query_incr::__rust_end_short_backtrace
  29:     0x7f9bf8f0d805 - rustc_hir_analysis[771be2d3202827d0]::coherence::coherent_trait
  30:     0x7f9bf8f0d521 - rustc_query_impl[ba2049ed27b9e923]::query_impl::coherent_trait::invoke_provider_fn::__rust_begin_short_backtrace
  31:     0x7f9bf8f35fa2 - rustc_query_impl[ba2049ed27b9e923]::execution::try_execute_query::<rustc_middle[7183fb41e9311d8f]::query::caches::DefIdCache<rustc_middle[7183fb41e9311d8f]::query::erase::ErasedData<[u8; 1usize]>>, true>
  32:     0x7f9bf9809bcd - rustc_query_impl[ba2049ed27b9e923]::query_impl::coherent_trait::execute_query_incr::__rust_end_short_backtrace
  33:     0x7f9bf9a19169 - rustc_hir_analysis[771be2d3202827d0]::check::check::check_item_type
  34:     0x7f9bf9a10cf2 - rustc_hir_analysis[771be2d3202827d0]::check::wfcheck::check_well_formed
  35:     0x7f9bf9a10cd3 - rustc_query_impl[ba2049ed27b9e923]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  36:     0x7f9bf8f38d86 - rustc_query_impl[ba2049ed27b9e923]::execution::try_execute_query::<rustc_data_structures[86f60c62854a1a76]::vec_cache::VecCache<rustc_span[9b2c1fda2845f7b9]::def_id::LocalDefId, rustc_middle[7183fb41e9311d8f]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[7183fb41e9311d8f]::dep_graph::graph::DepNodeIndex>, true>
  37:     0x7f9bf8f383d1 - rustc_query_impl[ba2049ed27b9e923]::query_impl::check_well_formed::execute_query_incr::__rust_end_short_backtrace
  38:     0x7f9bf742bc2d - <rustc_middle[7183fb41e9311d8f]::hir::ModuleItems>::par_opaques::<rustc_hir_analysis[771be2d3202827d0]::check::wfcheck::check_type_wf::{closure#5}>::{closure#0}
  39:     0x7f9bf74d1d1b - <rustc_thread_pool[45e85249471ab754]::job::HeapJob<<rustc_thread_pool[45e85249471ab754]::scope::Scope>::spawn<rustc_data_structures[86f60c62854a1a76]::sync::parallel::par_slice<&rustc_hir[2f50cfae1daf0a82]::hir::ImplItemId, rustc_data_structures[86f60c62854a1a76]::sync::parallel::try_par_for_each_in<&[rustc_hir[2f50cfae1daf0a82]::hir::ImplItemId], rustc_span[9b2c1fda2845f7b9]::ErrorGuaranteed, <rustc_middle[7183fb41e9311d8f]::hir::ModuleItems>::par_impl_items<rustc_hir_analysis[771be2d3202827d0]::check::wfcheck::check_type_wf::{closure#1}>::{closure#0}>::{closure#0}::{closure#0}>::{closure#1}::{closure#0}>::{closure#0}> as rustc_thread_pool[45e85249471ab754]::job::Job>::execute
  40:     0x7f9bf80f64bf - <rustc_thread_pool[45e85249471ab754]::registry::WorkerThread>::wait_or_steal_until_cold
  41:     0x7f9bf80f5062 - <rustc_thread_pool[45e85249471ab754]::registry::ThreadBuilder>::run
  42:     0x7f9bf72a20ec - std[f97f41f4b941f83d]::sys::backtrace::__rust_begin_short_backtrace::<<rustc_thread_pool[45e85249471ab754]::ThreadPoolBuilder>::build_scoped<rustc_interface[dd2c291cbeac3c6e]::util::run_in_thread_pool_with_globals<rustc_interface[dd2c291cbeac3c6e]::interface::run_compiler<(), rustc_driver_impl[94c2fdbf68adad86]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[dd2c291cbeac3c6e]::util::run_in_thread_pool_with_globals<rustc_interface[dd2c291cbeac3c6e]::interface::run_compiler<(), rustc_driver_impl[94c2fdbf68adad86]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>
  43:     0x7f9bf72ab95a - <std[f97f41f4b941f83d]::thread::lifecycle::spawn_unchecked<<rustc_thread_pool[45e85249471ab754]::ThreadPoolBuilder>::build_scoped<rustc_interface[dd2c291cbeac3c6e]::util::run_in_thread_pool_with_globals<rustc_interface[dd2c291cbeac3c6e]::interface::run_compiler<(), rustc_driver_impl[94c2fdbf68adad86]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#0}, rustc_interface[dd2c291cbeac3c6e]::util::run_in_thread_pool_with_globals<rustc_interface[dd2c291cbeac3c6e]::interface::run_compiler<(), rustc_driver_impl[94c2fdbf68adad86]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#5}::{closure#0}::{closure#1}, ()>::{closure#0}::{closure#0}::{closure#0}, ()>::{closure#1} as core[d89867bba8befc45]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  44:     0x7f9bf9ddeb52 - <std[f97f41f4b941f83d]::sys::thread::unix::Thread>::new::thread_start
  45:     0x7f9bf32981b9 - <unknown>
  46:     0x7f9bf331d21c - <unknown>
  47:                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.98.0-nightly (42d7d5292 2026-06-15) 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 [specialization_graph_of] building specialization graph of trait `Foobar`
#1 [coherent_trait] coherence checking all impls of trait `Foobar`
#2 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.yqoNYHxs2mJh/rustc_testrunner_tmpdir_reporting.QC5ogv3zZwCi/mvce.rs:5:1: 5:55>` 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: aborting due to 1 previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0601`.

@rustbot label +F-generic_const_exprs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.