Skip to content

[ICE]: next solver regression var types encountered in structurally_relate_tys #158064

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -Znext-solver=globally
trait Trait {
    fn bar() -> impl Clone {
        1
    }
}

original:

//@compile-flags: -Znext-solver=globally
trait Trait {
    fn bar() -> impl Clone {
        1
    }
}

fn main() {}

Version information

rustc 1.98.0-nightly (3768ec06c 2026-06-18)
binary: rustc
commit-hash: 3768ec06c826ef667b65a7d084610a11baf10776
commit-date: 2026-06-18
host: x86_64-unknown-linux-gnu
release: 1.98.0-nightly
LLVM version: 22.1.7

Possibly related line of code:

b: I::Ty,
) -> RelateResult<I, I::Ty> {
let cx = relation.cx();
match (a.kind(), b.kind()) {
(ty::Infer(_), _) | (_, ty::Infer(_)) => {
// The caller should handle these cases!
panic!("var types encountered in structurally_relate_tys")
}
(ty::Bound(..), _) | (_, ty::Bound(..)) => {
panic!("bound types encountered in structurally_relate_tys")
}

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Znext-solver=globally

Program output

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


thread 'rustc' (750695) panicked at /rustc-dev/3768ec06c826ef667b65a7d084610a11baf10776/compiler/rustc_type_ir/src/relate.rs:366:13:
var types encountered in structurally_relate_tys
stack backtrace:
   0:     0x7f3d17d699e9 - <<std[1292569624e9b716]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[38fba46487091c0e]::fmt::Display>::fmt
   1:     0x7f3d1840ecc8 - core[38fba46487091c0e]::fmt::write
   2:     0x7f3d17d7fe16 - <std[1292569624e9b716]::sys::stdio::unix::Stderr as std[1292569624e9b716]::io::Write>::write_fmt
   3:     0x7f3d17d3ecde - std[1292569624e9b716]::panicking::default_hook::{closure#0}
   4:     0x7f3d17d5c6d3 - std[1292569624e9b716]::panicking::default_hook
   5:     0x7f3d16af7c31 - std[1292569624e9b716]::panicking::update_hook::<alloc[52cceba6d04e2820]::boxed::Box<rustc_driver_impl[813fb007208c0d75]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f3d17d5c9b2 - std[1292569624e9b716]::panicking::panic_with_hook
   7:     0x7f3d17d3edd4 - std[1292569624e9b716]::panicking::panic_handler::{closure#0}
   8:     0x7f3d17d332c9 - std[1292569624e9b716]::sys::backtrace::__rust_end_short_backtrace::<std[1292569624e9b716]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f3d17d4080d - __rustc[9054dd400ee94b8c]::rust_begin_unwind
  10:     0x7f3d147ab35c - core[38fba46487091c0e]::panicking::panic_fmt
  11:     0x7f3d18b6ae78 - rustc_type_ir[63e217560a209f14]::relate::structurally_relate_tys::<rustc_middle[2d654c4484766882]::ty::context::TyCtxt, rustc_type_ir[63e217560a209f14]::relate::solver_relating::SolverRelating<rustc_infer[b6f36a5a12ddc998]::infer::InferCtxt, rustc_middle[2d654c4484766882]::ty::context::TyCtxt>>::{closure#0}
  12:     0x7f3d18b68a2c - <rustc_middle[2d654c4484766882]::ty::Ty as rustc_type_ir[63e217560a209f14]::relate::Relate<rustc_middle[2d654c4484766882]::ty::context::TyCtxt>>::relate::<rustc_type_ir[63e217560a209f14]::relate::solver_relating::SolverRelating<rustc_infer[b6f36a5a12ddc998]::infer::InferCtxt, rustc_middle[2d654c4484766882]::ty::context::TyCtxt>>
  13:     0x7f3d1945d68f - <rustc_infer[b6f36a5a12ddc998]::infer::InferCtxt as rustc_type_ir[63e217560a209f14]::relate::solver_relating::RelateExt>::eq_structurally_relating_aliases::<rustc_middle[2d654c4484766882]::ty::Term>
  14:     0x7f3d19459d52 - <rustc_next_trait_solver[8c1bcbc6bf8ab5b]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[9d90dad76f06a425]::solve::delegate::SolverDelegate> as rustc_type_ir[63e217560a209f14]::search_graph::Delegate>::compute_goal::{closure#0}
  15:     0x7f3d19458046 - <rustc_type_ir[63e217560a209f14]::search_graph::SearchGraph<rustc_next_trait_solver[8c1bcbc6bf8ab5b]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[9d90dad76f06a425]::solve::delegate::SolverDelegate>, rustc_middle[2d654c4484766882]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}::{closure#2}
  16:     0x7f3d19454e86 - <rustc_type_ir[63e217560a209f14]::search_graph::SearchGraph<rustc_next_trait_solver[8c1bcbc6bf8ab5b]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[9d90dad76f06a425]::solve::delegate::SolverDelegate>, rustc_middle[2d654c4484766882]::ty::context::TyCtxt>>::evaluate_goal
  17:     0x7f3d19392be3 - <rustc_next_trait_solver[8c1bcbc6bf8ab5b]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[9d90dad76f06a425]::solve::delegate::SolverDelegate, rustc_middle[2d654c4484766882]::ty::context::TyCtxt>>::evaluate_goal
  18:     0x7f3d188f6f54 - <rustc_trait_selection[9d90dad76f06a425]::solve::fulfill::FulfillmentCtxt<rustc_trait_selection[9d90dad76f06a425]::traits::FulfillmentError> as rustc_infer[b6f36a5a12ddc998]::traits::engine::TraitEngine<rustc_trait_selection[9d90dad76f06a425]::traits::FulfillmentError>>::try_evaluate_obligations
  19:     0x7f3d18727469 - <rustc_hir_typeck[5e25b61c51bd7463]::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
  20:     0x7f3d18fc9bd2 - rustc_hir_typeck[5e25b61c51bd7463]::check::check_fn
  21:     0x7f3d1886ff42 - rustc_hir_typeck[5e25b61c51bd7463]::typeck_with_inspect::{closure#0}
  22:     0x7f3d1886ce78 - rustc_query_impl[bc361d1a98410a93]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  23:     0x7f3d1886c3ed - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_data_structures[bcc76020f4c6983b]::vec_cache::VecCache<rustc_span[7ca2d96a75a336c7]::def_id::LocalDefId, rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[2d654c4484766882]::dep_graph::graph::DepNodeIndex>, false>
  24:     0x7f3d1886bd83 - rustc_query_impl[bc361d1a98410a93]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  25:     0x7f3d187e2d00 - rustc_mir_build[34ce9851331c84e7]::thir::pattern::check_match::check_match
  26:     0x7f3d187e2087 - rustc_query_impl[bc361d1a98410a93]::query_impl::check_match::invoke_provider_fn::__rust_begin_short_backtrace
  27:     0x7f3d19285b72 - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_data_structures[bcc76020f4c6983b]::vec_cache::VecCache<rustc_span[7ca2d96a75a336c7]::def_id::LocalDefId, rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[2d654c4484766882]::dep_graph::graph::DepNodeIndex>, false>
  28:     0x7f3d19285876 - rustc_query_impl[bc361d1a98410a93]::query_impl::check_match::execute_query_non_incr::__rust_end_short_backtrace
  29:     0x7f3d18f1aa90 - rustc_mir_build[34ce9851331c84e7]::builder::build_mir_inner_impl
  30:     0x7f3d1840f66a - rustc_mir_transform[4d03bc8eda5dec7]::mir_built
  31:     0x7f3d1886c3ed - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_data_structures[bcc76020f4c6983b]::vec_cache::VecCache<rustc_span[7ca2d96a75a336c7]::def_id::LocalDefId, rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[2d654c4484766882]::dep_graph::graph::DepNodeIndex>, false>
  32:     0x7f3d1886c083 - rustc_query_impl[bc361d1a98410a93]::query_impl::mir_built::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7f3d18454ffa - rustc_mir_transform[4d03bc8eda5dec7]::ffi_unwind_calls::has_ffi_unwind_calls
  34:     0x7f3d18454b19 - rustc_query_impl[bc361d1a98410a93]::query_impl::has_ffi_unwind_calls::invoke_provider_fn::__rust_begin_short_backtrace
  35:     0x7f3d19285b72 - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_data_structures[bcc76020f4c6983b]::vec_cache::VecCache<rustc_span[7ca2d96a75a336c7]::def_id::LocalDefId, rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[2d654c4484766882]::dep_graph::graph::DepNodeIndex>, false>
  36:     0x7f3d19285742 - rustc_query_impl[bc361d1a98410a93]::query_impl::has_ffi_unwind_calls::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7f3d19019e28 - rustc_mir_transform[4d03bc8eda5dec7]::mir_promoted
  38:     0x7f3d19019c92 - rustc_query_impl[bc361d1a98410a93]::query_impl::mir_promoted::invoke_provider_fn::__rust_begin_short_backtrace
  39:     0x7f3d1898bc05 - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_data_structures[bcc76020f4c6983b]::vec_cache::VecCache<rustc_span[7ca2d96a75a336c7]::def_id::LocalDefId, rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 16usize]>, rustc_middle[2d654c4484766882]::dep_graph::graph::DepNodeIndex>, false>
  40:     0x7f3d1925ffcb - rustc_query_impl[bc361d1a98410a93]::query_impl::mir_promoted::execute_query_non_incr::__rust_end_short_backtrace
  41:     0x7f3d192601a9 - rustc_borrowck[7e4c9d645627ad69]::mir_borrowck
  42:     0x7f3d192600a5 - rustc_query_impl[bc361d1a98410a93]::query_impl::mir_borrowck::invoke_provider_fn::__rust_begin_short_backtrace
  43:     0x7f3d1886c3ed - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_data_structures[bcc76020f4c6983b]::vec_cache::VecCache<rustc_span[7ca2d96a75a336c7]::def_id::LocalDefId, rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[2d654c4484766882]::dep_graph::graph::DepNodeIndex>, false>
  44:     0x7f3d18869403 - rustc_query_impl[bc361d1a98410a93]::query_impl::mir_borrowck::execute_query_non_incr::__rust_end_short_backtrace
  45:     0x7f3d193761ac - rustc_hir_analysis[8fdf28e36544864e]::collect::type_of::opaque::find_opaque_ty_constraints_for_rpit
  46:     0x7f3d19375ee8 - rustc_hir_analysis[8fdf28e36544864e]::collect::type_of::type_of_opaque
  47:     0x7f3d18424f8d - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_middle[2d654c4484766882]::query::caches::DefIdCache<rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 8usize]>>, false>
  48:     0x7f3d1958195c - rustc_query_impl[bc361d1a98410a93]::query_impl::type_of_opaque::execute_query_non_incr::__rust_end_short_backtrace
  49:     0x7f3d1868638b - rustc_hir_analysis[8fdf28e36544864e]::collect::type_of::type_of
  50:     0x7f3d18679de6 - rustc_query_impl[bc361d1a98410a93]::query_impl::type_of::invoke_provider_fn::__rust_begin_short_backtrace
  51:     0x7f3d18424f8d - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_middle[2d654c4484766882]::query::caches::DefIdCache<rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 8usize]>>, false>
  52:     0x7f3d18424b1c - rustc_query_impl[bc361d1a98410a93]::query_impl::type_of::execute_query_non_incr::__rust_end_short_backtrace
  53:     0x7f3d193767cb - rustc_hir_analysis[8fdf28e36544864e]::check::check::check_opaque
  54:     0x7f3d192a53a3 - rustc_hir_analysis[8fdf28e36544864e]::check::check::check_item_type
  55:     0x7f3d192865b2 - rustc_hir_analysis[8fdf28e36544864e]::check::wfcheck::check_well_formed
  56:     0x7f3d19286593 - rustc_query_impl[bc361d1a98410a93]::query_impl::check_well_formed::invoke_provider_fn::__rust_begin_short_backtrace
  57:     0x7f3d19285b72 - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_data_structures[bcc76020f4c6983b]::vec_cache::VecCache<rustc_span[7ca2d96a75a336c7]::def_id::LocalDefId, rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 1usize]>, rustc_middle[2d654c4484766882]::dep_graph::graph::DepNodeIndex>, false>
  58:     0x7f3d19285907 - rustc_query_impl[bc361d1a98410a93]::query_impl::check_well_formed::execute_query_non_incr::__rust_end_short_backtrace
  59:     0x7f3d19282438 - rustc_hir_analysis[8fdf28e36544864e]::check::wfcheck::check_type_wf
  60:     0x7f3d192822a1 - rustc_query_impl[bc361d1a98410a93]::query_impl::check_type_wf::invoke_provider_fn::__rust_begin_short_backtrace
  61:     0x7f3d1957a919 - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_middle[2d654c4484766882]::query::caches::SingleCache<rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 1usize]>>, false>
  62:     0x7f3d1957a6f7 - rustc_query_impl[bc361d1a98410a93]::query_impl::check_type_wf::execute_query_non_incr::__rust_end_short_backtrace
  63:     0x7f3d1886601e - rustc_hir_analysis[8fdf28e36544864e]::check_crate
  64:     0x7f3d188684cc - rustc_interface[679838e87ebde813]::passes::analysis
  65:     0x7f3d19578f46 - rustc_query_impl[bc361d1a98410a93]::execution::try_execute_query::<rustc_middle[2d654c4484766882]::query::caches::SingleCache<rustc_middle[2d654c4484766882]::query::erase::ErasedData<[u8; 0usize]>>, false>
  66:     0x7f3d19578c29 - rustc_query_impl[bc361d1a98410a93]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  67:     0x7f3d19540fd2 - rustc_interface[679838e87ebde813]::interface::run_compiler::<(), rustc_driver_impl[813fb007208c0d75]::run_compiler::{closure#0}>::{closure#1}
  68:     0x7f3d19591afa - std[1292569624e9b716]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[679838e87ebde813]::util::run_in_thread_with_globals<rustc_interface[679838e87ebde813]::util::run_in_thread_pool_with_globals<rustc_interface[679838e87ebde813]::interface::run_compiler<(), rustc_driver_impl[813fb007208c0d75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  69:     0x7f3d195918ad - <std[1292569624e9b716]::thread::lifecycle::spawn_unchecked<rustc_interface[679838e87ebde813]::util::run_in_thread_with_globals<rustc_interface[679838e87ebde813]::util::run_in_thread_pool_with_globals<rustc_interface[679838e87ebde813]::interface::run_compiler<(), rustc_driver_impl[813fb007208c0d75]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[38fba46487091c0e]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  70:     0x7f3d19587dd0 - <std[1292569624e9b716]::sys::thread::unix::Thread>::new::thread_start
  71:     0x7f3d12a981b9 - <unknown>
  72:     0x7f3d12b1d21c - <unknown>
  73:                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 (3768ec06c 2026-06-18) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally -Z dump-mir-dir=dir

query stack during panic:
#0 [typeck_root] type-checking `Trait::bar`
#1 [check_match] match-checking `Trait::bar`
#2 [mir_built] building MIR for `Trait::bar`
#3 [has_ffi_unwind_calls] checking if `Trait::bar` contains FFI-unwind calls
#4 [mir_promoted] promoting constants in MIR for `Trait::bar`
#5 [mir_borrowck] borrow-checking `Trait::bar`
#6 [type_of_opaque] computing type of opaque `Trait::bar::{opaque#0}`
#7 [type_of] computing type of `Trait::bar::{opaque#0}`
#8 [check_well_formed] checking that `Trait::bar::{opaque#0}` is well-formed
#9 [check_type_wf] checking that types are well-formed
#10 [analysis] running analysis passes on crate `mvce`
end of query stack
error: aborting due to 1 previous error

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

@rustbot label +WG-trait-system-refactor

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.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.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions