rust-lang / rust-lang/rust

ICE: assertion failed: ` .. var_values: [{type error}] ` vs ` .. var_values: [Alias(Opaque, AliasTy {...`

Open
#151,307 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug F-min_generic_const_args F-return_type_notation I-ICE T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
#![feature(min_generic_const_args)]
trait Trait {
    fn foo() -> impl Copy {}
}

impl Trait for () {
    fn foo() -> impl Copy
    where
        Self::foo(..): Copy,
    {
    }
}

original:

trait Trait {
    fn foo() -> impl Copy
    where [(); T::ABC]: Sized
    {
        String::from("temporary")
    }
}

impl Trait for () {
    fn foo() -> impl Copy
    where
        Self::foo(..): Copy
    {
        String::from("temporary")
    }
}

fn foo() -> impl Copy
    where
        Self::foo(..): Copy
    {
        String::from("temporary")
    }

Version information

rustc 1.95.0-nightly (621d76794 2026-01-18)
binary: rustc
commit-hash: 621d76794c76fc21c0a6151fbc090120e0230a91
commit-date: 2026-01-18
host: x86_64-unknown-linux-gnu
release: 1.95.0-nightly
LLVM version: 21.1.8

Possibly related line of code:
https://github.com/rust-lang/rust/blob/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_type_ir/src/search_graph/global_cache.rs#L60-L72

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zcrate-attr=feature(min_generic_const_args) -Znext-solver=globally

Program output

error[E0658]: return type notation is experimental
 --> /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:8:18
  |
8 |         Self::foo(..): Copy,
  |                  ^^^^
  |
  = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information
  = help: add `#![feature(return_type_notation)]` to the crate attributes to enable
  = note: this compiler was built on 2026-01-18; consider upgrading it if it is out of date

warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
 --> <crate attribute>:1:12
  |
1 | #![feature(min_generic_const_args)]
  |            ^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = note: `#[warn(incomplete_features)]` on by default

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

error[E0391]: cycle detected when computing type of `<impl at /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:5:1: 5:18>::foo::{anon_assoc#0}`
 --> /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:6:17
  |
6 |     fn foo() -> impl Copy
  |                 ^^^^^^^^^
  |
note: ...which requires comparing an impl and trait method signature, inferring any hidden `impl Trait` types in the process...
 --> /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:6:5
  |
6 | /     fn foo() -> impl Copy
7 | |     where
8 | |         Self::foo(..): Copy,
  | |____________________________^
  = note: ...which again requires computing type of `<impl at /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:5:1: 5:18>::foo::{anon_assoc#0}`, completing the cycle
note: cycle used when checking assoc item `<impl at /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:5:1: 5:18>::foo` is compatible with trait definition
 --> /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:6:5
  |
6 | /     fn foo() -> impl Copy
7 | |     where
8 | |         Self::foo(..): Copy,
  | |____________________________^
  = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information


thread 'rustc' (1113364) panicked at /rustc-dev/621d76794c76fc21c0a6151fbc090120e0230a91/compiler/rustc_type_ir/src/search_graph/global_cache.rs:66:17:
assertion `left == right` failed
  left: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [{type error}] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, var_kinds: [] })
 right: Ok(Canonical { value: Response { certainty: Yes, var_values: CanonicalVarValues { var_values: [Alias(Opaque, AliasTy { args: [], def_id: DefId(0:8 ~ mvce[a621]::{impl#0}::foo::{opaque#0}), .. })] }, external_constraints: ExternalConstraints(ExternalConstraintsData { region_constraints: [], opaque_types: [], normalization_nested_goals: NestedNormalizationGoals([]) }) }, max_universe: U0, var_kinds: [] })
stack backtrace:
   0:     0x7fb28dc33fd3 - <<std[287527946f71f0bc]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[7477a31a1a34cc49]::fmt::Display>::fmt
   1:     0x7fb28e20e2c8 - core[7477a31a1a34cc49]::fmt::write
   2:     0x7fb28dc4a9c6 - <std[287527946f71f0bc]::sys::stdio::unix::Stderr as std[287527946f71f0bc]::io::Write>::write_fmt
   3:     0x7fb28dc0a048 - std[287527946f71f0bc]::panicking::default_hook::{closure#0}
   4:     0x7fb28dc27703 - std[287527946f71f0bc]::panicking::default_hook
   5:     0x7fb28cbfbb8a - std[287527946f71f0bc]::panicking::update_hook::<alloc[979041e9952e771b]::boxed::Box<rustc_driver_impl[517260a07841a630]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7fb28dc279e2 - std[287527946f71f0bc]::panicking::panic_with_hook
   7:     0x7fb28dc0a108 - std[287527946f71f0bc]::panicking::panic_handler::{closure#0}
   8:     0x7fb28dc00dc9 - std[287527946f71f0bc]::sys::backtrace::__rust_end_short_backtrace::<std[287527946f71f0bc]::panicking::panic_handler::{closure#0}, !>
   9:     0x7fb28dc0bbdd - __rustc[5ec7081ce87b032f]::rust_begin_unwind
  10:     0x7fb28a70cfbc - core[7477a31a1a34cc49]::panicking::panic_fmt
  11:     0x7fb28c57d6d3 - core[7477a31a1a34cc49]::panicking::assert_failed_inner
  12:     0x7fb28d966d74 - core[7477a31a1a34cc49]::panicking::assert_failed::<core[7477a31a1a34cc49]::result::Result<rustc_type_ir[b93cf349b3a4f34d]::canonical::Canonical<rustc_middle[725063e074f29df]::ty::context::TyCtxt, rustc_type_ir[b93cf349b3a4f34d]::solve::Response<rustc_middle[725063e074f29df]::ty::context::TyCtxt>>, rustc_type_ir[b93cf349b3a4f34d]::solve::NoSolution>, core[7477a31a1a34cc49]::result::Result<rustc_type_ir[b93cf349b3a4f34d]::canonical::Canonical<rustc_middle[725063e074f29df]::ty::context::TyCtxt, rustc_type_ir[b93cf349b3a4f34d]::solve::Response<rustc_middle[725063e074f29df]::ty::context::TyCtxt>>, rustc_type_ir[b93cf349b3a4f34d]::solve::NoSolution>>
  13:     0x7fb28ee35f08 - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate, rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::evaluate_goal_raw
  14:     0x7fb28ee222a5 - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate, rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::try_evaluate_added_goals
  15:     0x7fb28ee1bbfe - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate> as rustc_type_ir[b93cf349b3a4f34d]::search_graph::Delegate>::compute_goal::{closure#0}
  16:     0x7fb28ee323a3 - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate, rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::evaluate_goal_raw
  17:     0x7fb28ee21ef4 - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate, rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::try_evaluate_added_goals
  18:     0x7fb28f12af23 - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate, rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::compute_trait_goal
  19:     0x7fb28ee1b74f - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate> as rustc_type_ir[b93cf349b3a4f34d]::search_graph::Delegate>::compute_goal::{closure#0}
  20:     0x7fb28ee323a3 - <rustc_next_trait_solver[2bc6883c9be4be93]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate, rustc_middle[725063e074f29df]::ty::context::TyCtxt>>::evaluate_goal_raw
  21:     0x7fb28ee31489 - <rustc_trait_selection[9fee51d8a10a777c]::solve::delegate::SolverDelegate as rustc_next_trait_solver[2bc6883c9be4be93]::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
  22:     0x7fb28ee23186 - <rustc_trait_selection[9fee51d8a10a777c]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[9fee51d8a10a777c]::traits::FulfillmentError> as rustc_infer[5a785d1c27494969]::traits::engine::TraitEngine<rustc_trait_selection[9fee51d8a10a777c]::traits::FulfillmentError>>::try_evaluate_obligations
  23:     0x7fb28ee22d29 - <rustc_trait_selection[9fee51d8a10a777c]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[9fee51d8a10a777c]::traits::FulfillmentError> as rustc_infer[5a785d1c27494969]::traits::engine::TraitEngine<rustc_trait_selection[9fee51d8a10a777c]::traits::FulfillmentError>>::evaluate_obligations_error_on_ambiguity
  24:     0x7fb28ebe0b3c - rustc_hir_analysis[1a80394817eddfdd]::check::compare_impl_item::compare_impl_item
  25:     0x7fb28ebdea99 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::compare_impl_item::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>
  26:     0x7fb28e992f78 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_data_structures[e0d8483206daafa2]::vec_cache::VecCache<rustc_span[851f35e07e3c2dd4]::def_id::LocalDefId, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[b7e73caa2c2ad9a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  27:     0x7fb28e992a51 - rustc_query_impl[f20b8284200e680a]::query_impl::compare_impl_item::get_query_non_incr::__rust_end_short_backtrace
  28:     0x7fb28e995eaa - rustc_hir_analysis[1a80394817eddfdd]::check::check::check_item_type
  29:     0x7fb28e99379c - rustc_hir_analysis[1a80394817eddfdd]::check::wfcheck::check_well_formed
  30:     0x7fb28e99376b - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::check_well_formed::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>
  31:     0x7fb28e9931e3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_data_structures[e0d8483206daafa2]::vec_cache::VecCache<rustc_span[851f35e07e3c2dd4]::def_id::LocalDefId, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>, rustc_query_system[b7e73caa2c2ad9a]::dep_graph::graph::DepNodeIndex>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  32:     0x7fb28e992cd6 - rustc_query_impl[f20b8284200e680a]::query_impl::check_well_formed::get_query_non_incr::__rust_end_short_backtrace
  33:     0x7fb28e990470 - rustc_hir_analysis[1a80394817eddfdd]::check::wfcheck::check_type_wf
  34:     0x7fb28e99035d - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::check_type_wf::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>
  35:     0x7fb28f3a3e85 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 1usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  36:     0x7fb28f3a3b36 - rustc_query_impl[f20b8284200e680a]::query_impl::check_type_wf::get_query_non_incr::__rust_end_short_backtrace
  37:     0x7fb28ed3f316 - rustc_hir_analysis[1a80394817eddfdd]::check_crate
  38:     0x7fb28e3493db - rustc_interface[5c48368f5debe80d]::passes::analysis
  39:     0x7fb28e349035 - rustc_query_impl[f20b8284200e680a]::plumbing::__rust_begin_short_backtrace::<rustc_query_impl[f20b8284200e680a]::query_impl::analysis::dynamic_query::{closure#2}::{closure#0}, rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>
  40:     0x7fb28f3a4be3 - rustc_query_system[b7e73caa2c2ad9a]::query::plumbing::try_execute_query::<rustc_query_impl[f20b8284200e680a]::DynamicConfig<rustc_query_system[b7e73caa2c2ad9a]::query::caches::SingleCache<rustc_middle[725063e074f29df]::query::erase::Erased<[u8; 0usize]>>, false, false, false>, rustc_query_impl[f20b8284200e680a]::plumbing::QueryCtxt, false>
  41:     0x7fb28f3a49ce - rustc_query_impl[f20b8284200e680a]::query_impl::analysis::get_query_non_incr::__rust_end_short_backtrace
  42:     0x7fb28f582c11 - <rustc_interface[5c48368f5debe80d]::passes::create_and_enter_global_ctxt<core[7477a31a1a34cc49]::option::Option<rustc_interface[5c48368f5debe80d]::queries::Linker>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2}>::{closure#2} as core[7477a31a1a34cc49]::ops::function::FnOnce<(&rustc_session[eb79e6d3104f29ae]::session::Session, rustc_middle[725063e074f29df]::ty::context::CurrentGcx, alloc[979041e9952e771b]::sync::Arc<rustc_data_structures[e0d8483206daafa2]::jobserver::Proxy>, &std[287527946f71f0bc]::sync::once_lock::OnceLock<rustc_middle[725063e074f29df]::ty::context::GlobalCtxt>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_middle[725063e074f29df]::arena::Arena>, &rustc_data_structures[e0d8483206daafa2]::sync::worker_local::WorkerLocal<rustc_hir[7eac7792dedc1861]::Arena>, rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}::{closure#2})>>::call_once::{shim:vtable#0}
  43:     0x7fb28f3f5d34 - rustc_interface[5c48368f5debe80d]::interface::run_compiler::<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}
  44:     0x7fb28f35aa3a - std[287527946f71f0bc]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  45:     0x7fb28f35a7fe - <std[287527946f71f0bc]::thread::lifecycle::spawn_unchecked<rustc_interface[5c48368f5debe80d]::util::run_in_thread_with_globals<rustc_interface[5c48368f5debe80d]::util::run_in_thread_pool_with_globals<rustc_interface[5c48368f5debe80d]::interface::run_compiler<(), rustc_driver_impl[517260a07841a630]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[7477a31a1a34cc49]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  46:     0x7fb28f35c5c4 - <std[287527946f71f0bc]::sys::thread::unix::Thread>::new::thread_start
  47:     0x7fb288c9698b - <unknown>
  48:     0x7fb288d1a9cc - <unknown>
  49:                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.95.0-nightly (621d76794 2026-01-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z crate-attr=feature(min_generic_const_args) -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [compare_impl_item] checking assoc item `<impl at /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:5:1: 5:18>::foo` is compatible with trait definition
#1 [check_well_formed] checking that `<impl at /tmp/icemaker_global_tempdir.w08EPnpWwZh8/rustc_testrunner_tmpdir_reporting.Ehj8dz8mFpzP/mvce.rs:5:1: 5:18>` is well-formed
#2 [check_type_wf] checking that types are well-formed
#3 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 3 previous errors; 1 warning emitted

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

@rustbot label +F-min_generic_const_args +WG-trait-system-refactor

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.

Research direction

Reproduce the reduced Rust case with -Znext-solver=globally and the min_generic_const_args feature. Then inspect compiler/rustc_type_ir/src/search_graph/global_cache.rs:60-72 and the surrounding trait-solver path; done means this input no longer triggers the reported assertion panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.