Skip to content

Panic: assertion left == right failed in normalize_associated_types_in when normalizing nested associated type projection #21099

@lexoliu

Description

@lexoliu

rust-analyzer version: rust-analyzer version: 0.3.2683-standalone (2efc800 2025-11-11)
rustc version: rustc 1.91.1 (ed61e7d7e 2025-11-07)

editor or extension: VSCode 1.106.1 with rust-analyzer plugin 0.3.2683

relevant settings: default

repository link (if public, optional): https://github.com/lexoliu/executor-core, commit: 1ac45d

Summary

When I attempted to open tokio.rs file

rust-analyzer panics with:

assertion left == right failed

inside:

crates/hir-ty/src/next_solver/normalize.rs:48:5

while trying to normalize a nested associated-type projection in my coroutine/task executor code.

This panic happens during:

  • diagnostics
  • inlay hints
  • semantic tokens

cargo check works fine; only rust-analyzer crashes.

Full panic message

thread 'Worker5' (6545530) panicked at crates/hir-ty/src/next_solver/normalize.rs:48:5:
assertion `left == right` failed
  left: [Goal { param_env: ParamEnv { clauses: [] }, predicate: Binder { value: AliasRelate(Alias(Projection, AliasTy { args: [Runtime, Alias(Projection, AliasTy { args: [Coroutine(InternedCoroutineId(InternedCoroutineId { loc: InternedCoroutine(FunctionId(FunctionId(a77b)), Idx::<Expr>(7)) }), [(), (), (), ?0i, ()])], def_id: TypeAliasId("Output"), .. })], def_id: TypeAliasId("Task"), .. }), Equate, ?9t), bound_vars: [] } }]
 right: []
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::assert_failed_inner
   3: core::panicking::assert_failed
   4: hir_ty::infer::unify::InferenceTable::normalize_associated_types_in
   5: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
   6: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_coerce
   7: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_block
   8: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner::{{closure}}
   9: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_expr_inner
  10: hir_ty::infer::expr::<impl hir_ty::infer::InferenceContext>::infer_return
  11: hir_ty::infer::infer_query
  12: salsa::function::execute::<impl salsa::function::IngredientImpl<C>>::execute
  13: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold_with_retry
  14: std::thread::local::LocalKey<T>::with
  15: <DB as hir_ty::db::HirDatabase>::infer
  16: hir::DefWithBody::diagnostics
  17: hir::ModuleDef::diagnostics
  18: hir::Module::diagnostics
  19: hir::Module::diagnostics
  20: ide_diagnostics::semantic_diagnostics
  21: ide_diagnostics::full_diagnostics
  22: salsa::cancelled::Cancelled::catch
  23: std::thread::local::LocalKey<T>::with
  24: ide::Analysis::assists_with_fixes
  25: rust_analyzer::handlers::request::handle_code_action
  26: core::ops::function::FnOnce::call_once{{vtable.shim}}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Reproduce code snippets

I guess it was something wrong with the mod test in tokio.rs file, since the panic disappears if I removed whole test module. However, since the dependencies in this crate are quite complex. I can't reproduce it in a smaller code snippet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions