rust-lang / rust-lang/rust

[ICE]: `unexpected self type for 'Goal'`

Open
#159,102 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug I-ICE needs-triage T-compiler WG-trait-system-refactor
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

probably related to https://github.com/rust-lang/rust/issues/159101

Code
// -Znext-solver=globally
trait Test {
    type T;
    const C: Self::T;
    fn lower() -> Test<C = { Test::T }, T = <Self as Test>::T>;
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.99.0-nightly (af3d95584 2026-07-09)
binary: rustc
commit-hash: af3d95584dbddcae597890340995509a7fb47a50
commit-date: 2026-07-09
host: x86_64-unknown-linux-gnu
release: 1.99.0-nightly
LLVM version: 22.1.8
Error output
error[E0658]: associated const equality is incomplete
 --> code.rs:4:24
  |
4 |     fn lower() -> Test<C = { Test::T }, T = <Self as Test>::T>;
  |                        ^^^^^^^^^^^^^^^
  |
  = note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
  = help: add `#![feature(min_generic_const_args)]` to the crate attributes to enable
  = note: this compiler was built on 2026-07-09; consider upgrading it if it is out of date

warning: trait objects without an explicit `dyn` are deprecated
 --> code.rs:4:19
  |
4 |     fn lower() -> Test<C = { Test::T }, T = <Self as Test>::T>;
  |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
  = note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/warnings-promoted-to-error.html>
  = note: `#[warn(bare_trait_objects)]` (part of `#[warn(rust_2021_compatibility)]`) on by default
help: if this is a dyn-compatible trait, use `dyn`
  |
4 |     fn lower() -> dyn Test<C = { Test::T }, T = <Self as Test>::T>;
  |                   +++

error[E0038]: the trait `Test` is not dyn compatible
 --> code.rs:4:19
  |
4 |     fn lower() -> Test<C = { Test::T }, T = <Self as Test>::T>;
  |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Test` is not dyn compatible
  |
note: for a trait to be dyn compatible it needs to allow building a vtable
      for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility>
 --> code.rs:3:11
  |
1 | trait Test {
  |       ---- this trait is not dyn compatible...
2 |     type T;
3 |     const C: Self::T;
  |           ^ ...because it contains associated const `C`
4 |     fn lower() -> Test<C = { Test::T }, T = <Self as Test>::T>;
  |        ^^^^^ ...because associated function `lower` has no `self` parameter
  = help: consider moving `C` to another trait
help: consider turning `lower` into a method by giving it a `&self` argument
  |
4 |     fn lower(&self) -> Test<C = { Test::T }, T = <Self as Test>::T>;
  |              +++++
help: alternatively, consider constraining `lower` so it does not apply to trait objects
  |
4 |     fn lower() -> Test<C = { Test::T }, T = <Self as Test>::T> where Self: Sized;
  |                                                                +++++++++++++++++
help: you might have meant to use `Self` to refer to the implementing type
  |
4 -     fn lower() -> Test<C = { Test::T }, T = <Self as Test>::T>;
4 +     fn lower() -> Self;
Backtrace

thread 'rustc' (2866160) panicked at /rustc-dev/af3d95584dbddcae597890340995509a7fb47a50/compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs:769:17:
unexpected self type for `Goal { param_env: ParamEnv { caller_bounds: [] }, predicate: TraitPredicate(<FreshTy(0) as Test>, polarity:Positive) }`
stack backtrace:
   0:     0x7f67ab30d266 - <<std[40ec4738f960212f]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[f94227772a84a350]::fmt::Display>::fmt
   1:     0x7f67aba0ee08 - core[f94227772a84a350]::fmt::write
   2:     0x7f67ab32264c - <std[40ec4738f960212f]::sys::stdio::unix::Stderr as std[40ec4738f960212f]::io::Write>::write_fmt
   3:     0x7f67ab2e156a - std[40ec4738f960212f]::panicking::default_hook::{closure#0}
   4:     0x7f67ab2ff923 - std[40ec4738f960212f]::panicking::default_hook
   5:     0x7f67aa2e4828 - std[40ec4738f960212f]::panicking::update_hook::<alloc[15af67eb22419dcd]::boxed::Box<rustc_driver_impl[4720cc46e2ef7529]::install_ice_hook::{closure#1}>>::{closure#0}
   6:     0x7f67ab2ffdc2 - std[40ec4738f960212f]::panicking::panic_with_hook
   7:     0x7f67ab2e1622 - std[40ec4738f960212f]::panicking::panic_handler::{closure#0}
   8:     0x7f67ab2d5b09 - std[40ec4738f960212f]::sys::backtrace::__rust_end_short_backtrace::<std[40ec4738f960212f]::panicking::panic_handler::{closure#0}, !>
   9:     0x7f67ab2e2f8d - __rustc[4a4b9b94957988a7]::rust_begin_unwind
  10:     0x7f67a847b3dc - core[f94227772a84a350]::panicking::panic_fmt
  11:     0x7f67ac746dc5 - <rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::assemble_alias_bound_candidates_recur::<rustc_type_ir[d247da7ee518b5fa]::predicate::TraitPredicate<rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>
  12:     0x7f67acfd7c04 - <rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::compute_trait_goal
  13:     0x7f67acc4bc7e - <rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate> as rustc_type_ir[d247da7ee518b5fa]::search_graph::Delegate>::compute_goal::{closure#0}
  14:     0x7f67a8c5c803 - <rustc_type_ir[d247da7ee518b5fa]::search_graph::SearchGraph<rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate>, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
  15:     0x7f67ac5c1b63 - <rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::evaluate_goal_cold
  16:     0x7f67acc4b93e - <rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate> as rustc_type_ir[d247da7ee518b5fa]::search_graph::Delegate>::compute_goal::{closure#0}
  17:     0x7f67a8c5c803 - <rustc_type_ir[d247da7ee518b5fa]::search_graph::SearchGraph<rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::search_graph::SearchGraphDelegate<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate>, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::evaluate_goal::{closure#0}
  18:     0x7f67ac5c1b63 - <rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::eval_ctxt::EvalCtxt<rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::evaluate_goal_cold
  19:     0x7f67ac9d3f78 - <rustc_trait_selection[27d012fca9780532]::solve::delegate::SolverDelegate as rustc_next_trait_solver[5e27b30a7c27b9e6]::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
  20:     0x7f67ac9d3c27 - <rustc_next_trait_solver[5e27b30a7c27b9e6]::normalize::NormalizationFolder<rustc_infer[746a1668c57c4cb2]::infer::InferCtxt, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt, rustc_trait_selection[27d012fca9780532]::solve::normalize::normalize_with_universes<rustc_type_ir[d247da7ee518b5fa]::ty_kind::FnSig<rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::{closure#0}>>::normalize_alias_term
  21:     0x7f67ac9d104a - <rustc_next_trait_solver[5e27b30a7c27b9e6]::normalize::NormalizationFolder<rustc_infer[746a1668c57c4cb2]::infer::InferCtxt, rustc_middle[422739edb7f5a344]::ty::context::TyCtxt, rustc_trait_selection[27d012fca9780532]::solve::normalize::normalize_with_universes<rustc_middle[422739edb7f5a344]::ty::Ty>::{closure#0}> as rustc_type_ir[d247da7ee518b5fa]::fold::FallibleTypeFolder<rustc_middle[422739edb7f5a344]::ty::context::TyCtxt>>::try_fold_ty::{closure#0}
  22:     0x7f67abcb552c - <rustc_hir_typeck[3b7c08c8b12220d6]::fn_ctxt::FnCtxt>::normalize::<rustc_middle[422739edb7f5a344]::ty::Ty>
  23:     0x7f67ac84bb5d - rustc_hir_typeck[3b7c08c8b12220d6]::typeck_with_inspect::{closure#0}
  24:     0x7f67ac847d00 - rustc_query_impl[1cd46de70f375db8]::query_impl::typeck_root::invoke_provider_fn::__rust_begin_short_backtrace
  25:     0x7f67abe05a69 - rustc_query_impl[1cd46de70f375db8]::execution::try_execute_query::<rustc_data_structures[2651829cf25f0ae4]::vec_cache::VecCache<rustc_span[1e05f22eb29205e5]::def_id::LocalDefId, rustc_middle[422739edb7f5a344]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[422739edb7f5a344]::dep_graph::graph::DepNodeIndex>, false>
  26:     0x7f67abe054c3 - rustc_query_impl[1cd46de70f375db8]::query_impl::typeck_root::execute_query_non_incr::__rust_end_short_backtrace
  27:     0x7f67abe01684 - rustc_query_impl[1cd46de70f375db8]::query_impl::used_trait_imports::invoke_provider_fn::__rust_begin_short_backtrace
  28:     0x7f67abe05a69 - rustc_query_impl[1cd46de70f375db8]::execution::try_execute_query::<rustc_data_structures[2651829cf25f0ae4]::vec_cache::VecCache<rustc_span[1e05f22eb29205e5]::def_id::LocalDefId, rustc_middle[422739edb7f5a344]::query::erase::ErasedData<[u8; 8usize]>, rustc_middle[422739edb7f5a344]::dep_graph::graph::DepNodeIndex>, false>
  29:     0x7f67abe05583 - rustc_query_impl[1cd46de70f375db8]::query_impl::used_trait_imports::execute_query_non_incr::__rust_end_short_backtrace
  30:     0x7f67abe04d25 - rustc_hir_analysis[90a6b1f5d8033815]::check_unused::check_unused_traits
  31:     0x7f67acbd5487 - rustc_query_impl[1cd46de70f375db8]::execution::try_execute_query::<rustc_middle[422739edb7f5a344]::query::caches::SingleCache<rustc_middle[422739edb7f5a344]::query::erase::ErasedData<[u8; 0usize]>>, false>
  32:     0x7f67acbd51e9 - rustc_query_impl[1cd46de70f375db8]::query_impl::check_unused_traits::execute_query_non_incr::__rust_end_short_backtrace
  33:     0x7f67abe022e2 - rustc_hir_analysis[90a6b1f5d8033815]::check_crate
  34:     0x7f67abe0677a - rustc_interface[96c4102e2fe97684]::passes::analysis
  35:     0x7f67acbd5487 - rustc_query_impl[1cd46de70f375db8]::execution::try_execute_query::<rustc_middle[422739edb7f5a344]::query::caches::SingleCache<rustc_middle[422739edb7f5a344]::query::erase::ErasedData<[u8; 0usize]>>, false>
  36:     0x7f67acbd5169 - rustc_query_impl[1cd46de70f375db8]::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
  37:     0x7f67acbb18ce - rustc_interface[96c4102e2fe97684]::interface::run_compiler::<(), rustc_driver_impl[4720cc46e2ef7529]::run_compiler::{closure#0}>::{closure#1}
  38:     0x7f67acbec1fa - std[40ec4738f960212f]::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface[96c4102e2fe97684]::util::run_in_thread_with_globals<rustc_interface[96c4102e2fe97684]::util::run_in_thread_pool_with_globals<rustc_interface[96c4102e2fe97684]::interface::run_compiler<(), rustc_driver_impl[4720cc46e2ef7529]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
  39:     0x7f67acbebfad - <std[40ec4738f960212f]::thread::lifecycle::spawn_unchecked<rustc_interface[96c4102e2fe97684]::util::run_in_thread_with_globals<rustc_interface[96c4102e2fe97684]::util::run_in_thread_pool_with_globals<rustc_interface[96c4102e2fe97684]::interface::run_compiler<(), rustc_driver_impl[4720cc46e2ef7529]::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core[f94227772a84a350]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:     0x7f67acbe23ba - <std[40ec4738f960212f]::sys::thread::unix::Thread>::new::thread_start
  41:     0x7f67a64981b9 - <unknown>
  42:     0x7f67a651d21c - <unknown>
  43:                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: please attach the file at `/home/matthias/vcs/github/CRED/rustc-ice-2026-07-10T17_29_10-2866150.txt` to your bug report

note: rustc 1.99.0-nightly (af3d95584 2026-07-09) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z next-solver=globally

query stack during panic:
#0 [typeck_root] type-checking `Test::lower::{constant#0}`
#1 [used_trait_imports] finding used_trait_imports `Test::lower::{constant#0}`
#2 [check_unused_traits] checking unused trait imports in crate
#3 [analysis] running analysis passes on crate `code`
end of query stack
error: aborting due to 2 previous errors; 1 warning emitted

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

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

Start by reproducing the minimal example with -Znext-solver=globally, then inspect compiler/rustc_next_trait_solver/src/solve/assembly/mod.rs around line 769, where the panic occurs. Trace how the associated-const equality and trait-object goal reach that code. Done means the example no longer triggers an internal compiler panic and produces a normal diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.