rust-lang / rust-lang/rust-analyzer
panic: `ExistentialMismatch`
Open
Nobody has claimed this yet.
C-bug
I-panic
- Dominant language
- Rust
- Stars
- 16.9k
- Forks
- 2.2k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 72
Description
trait Sup<T> {
type Assoc;
}
impl<T> Sup<T> for () {
type Assoc = T;
}
trait Trait<A, B>: Sup<A, Assoc = A> + Sup<B, Assoc = B> {}
impl<T, U> Trait<T, U> for () {}
fn main() {
let x: &dyn Trait<(), _> = &();
let y: &dyn Trait<_, ()> = x;
}
code compiles with rustc
RUST_BACKTRACE=full rust-analyzer analysis-stats . --run-all-ide-things
Database loaded: 612.27ms, 224minstr, 48mb (metadata 319.50ms, 1011kinstr, 152kb; build 34.67ms, 179kinstr, 1744b)
item trees: 1
dependency lines of code: 1_462_633, item trees: 2_900
dependency item stats: traits: 851, impl: 9_701, mods: 3_012, macro calls: 5_501, macro rules: 1_053
Item Tree Collection: 4.15s, 22ginstr, 425mb
Total Statistics:
crates: 1, mods: 1, decls: 4, bodies: 1, adts: 0, consts: 0, signatures: 6, variants: 0
Workspace:
traits: 2, macro_rules macros: 0, proc_macros: 0
lines of code: 16, item trees: 1
usages: traits: 2, impl: 2, mods: 0, macro calls: 0, macro rules: 0
Dependencies:
lines of code: 1_462_633, item trees: 2_900
declarations: traits: 851, impl: 9_701, mods: 3_012, macro calls: 5_501, macro rules: 1_053
Item Collection: 2.47s, 11ginstr, 177mb
Crate lang items: 464.00ms, 2471minstr, 31mb
Expression Store Lowering: 396.40µs, 488kinstr, 9kb
0/1 0% processing: dummy::main
thread 'main' (2354605) panicked at /rust/deps/ra-ap-rustc_next_trait_solver-0.165.0/src/canonical/mod.rs:263:88:
called `Result::unwrap()` on an `Err` value: ExistentialMismatch(ExpectedFound { expected: [Binder { value: Trait(ExistentialTraitRef("Trait"[[(), ()]])), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [()], term: (), .. }), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [()], term: (), .. }), bound_vars: [] }], found: [Binder { value: Trait(ExistentialTraitRef("Trait"[[(), ?19t]])), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [?19t], term: ?19t, .. }), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [()], term: (), .. }), bound_vars: [] }] })
stack backtrace:
0: 0x7ff8eac43416 - <<std[5264d755c47072bd]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[435d43ddfce3abfa]::fmt::Display>::fmt
1: 0x7ff8eb20ec88 - core[435d43ddfce3abfa]::fmt::write
2: 0x7ff8eac5867c - <std[5264d755c47072bd]::sys::stdio::unix::Stderr as core[435d43ddfce3abfa]::io::write::Write>::write_fmt
3: 0x7ff8eac1558a - std[5264d755c47072bd]::panicking::default_hook::{closure#0}
4: 0x7ff8eac35b33 - std[5264d755c47072bd]::panicking::default_hook
5: 0x7ff8eac35f9b - std[5264d755c47072bd]::panicking::panic_with_hook
6: 0x7ff8eac15642 - std[5264d755c47072bd]::panicking::panic_handler::{closure#0}
7: 0x7ff8eac0dfc9 - std[5264d755c47072bd]::sys::backtrace::__rust_end_short_backtrace::<std[5264d755c47072bd]::panicking::panic_handler::{closure#0}, !>
8: 0x7ff8eac16f9d - __rustc[efc60ea9c7e5e02b]::rust_begin_unwind
9: 0x7ff8e793c8ec - core[435d43ddfce3abfa]::panicking::panic_fmt
10: 0x7ff8e733aac2 - core[435d43ddfce3abfa]::result::unwrap_failed
11: 0x558b8782ed6d - ra_ap_rustc_next_trait_solver[1e1bbc9a2ad92865]::canonical::unify_query_var_values::<hir_ty[a11d2f9205227a88]::next_solver::solver::SolverContext, hir_ty[a11d2f9205227a88]::next_solver::interner::DbInterner>
12: 0x558b87a3f9af - <hir_ty[a11d2f9205227a88]::next_solver::inspect::InspectCandidate>::instantiate_nested_goals
13: 0x558b877bb469 - <hir_ty[a11d2f9205227a88]::next_solver::inspect::InspectCandidate>::visit_nested_no_probe::<hir_ty[a11d2f9205227a88]::infer::coerce::CoerceVisitor<hir_ty[a11d2f9205227a88]::infer::coerce::InferenceCoercionDelegate>>
14: 0x558b87bcaf45 - <hir_ty[a11d2f9205227a88]::infer::coerce::CoerceVisitor<hir_ty[a11d2f9205227a88]::infer::coerce::InferenceCoercionDelegate> as hir_ty[a11d2f9205227a88]::next_solver::inspect::ProofTreeVisitor>::visit_goal
15: 0x558b877c4a99 - <hir_ty[a11d2f9205227a88]::next_solver::infer::InferCtxt>::visit_proof_tree::<hir_ty[a11d2f9205227a88]::infer::coerce::CoerceVisitor<hir_ty[a11d2f9205227a88]::infer::coerce::InferenceCoercionDelegate>>
16: 0x558b87996749 - <hir_ty[a11d2f9205227a88]::infer::coerce::Coerce<hir_ty[a11d2f9205227a88]::infer::coerce::InferenceCoercionDelegate>>::coerce
17: 0x558b87a2600d - <hir_ty[a11d2f9205227a88]::infer::InferenceContext>::coerce
18: 0x558b8798230b - <hir_ty[a11d2f9205227a88]::infer::InferenceContext>::infer_expr_inner
19: 0x558b87980047 - <hir_ty[a11d2f9205227a88]::infer::InferenceContext>::infer_return
20: 0x558b87ade5ce - hir_ty[a11d2f9205227a88]::infer::infer_query_with_inspect
21: 0x558b879ce114 - <salsa[bfa5eed162dfe307]::function::IngredientImpl<<hir_ty[a11d2f9205227a88]::infer::InferenceResult>::for_body::_::for_body__Configuration_>>::execute
22: 0x558b87798fe7 - <salsa[bfa5eed162dfe307]::attach::Attached>::attach::<dyn hir_ty[a11d2f9205227a88]::db::HirDatabase, &hir_ty[a11d2f9205227a88]::infer::InferenceResult, <hir_ty[a11d2f9205227a88]::infer::InferenceResult>::for_body::for_body_::{closure#0}>
23: 0x558b8873bc6f - <rust_analyzer[54a442221c605e5]::cli::flags::AnalysisStats>::run_inference
24: 0x558b886e8cd4 - <rust_analyzer[54a442221c605e5]::cli::flags::AnalysisStats>::run::{closure#3}
25: 0x558b88747e69 - <rust_analyzer[54a442221c605e5]::cli::flags::AnalysisStats>::run
26: 0x558b889f1272 - rust_analyzer[25166d87b799c29f]::main
27: 0x558b88987aa3 - std[5264d755c47072bd]::sys::backtrace::__rust_begin_short_backtrace::<fn() -> core[435d43ddfce3abfa]::result::Result<std[5264d755c47072bd]::process::ExitCode, anyhow[f9c252109e1c84fa]::Error>, core[435d43ddfce3abfa]::result::Result<std[5264d755c47072bd]::process::ExitCode, anyhow[f9c252109e1c84fa]::Error>>
28: 0x558b889ea412 - std[5264d755c47072bd]::rt::lang_start::<core[435d43ddfce3abfa]::result::Result<std[5264d755c47072bd]::process::ExitCode, anyhow[f9c252109e1c84fa]::Error>>::{closure#0}
29: 0x7ff8ec414e99 - std[5264d755c47072bd]::rt::lang_start_internal
30: 0x558b88a0a4f8 - main
31: 0x7ff8e5c27741 - <unknown>
32: 0x7ff8e5c27879 - __libc_start_main
33: 0x558b872fc369 - <unknown>
34: 0x0 - <unknown>
infer panicked for dummy::main: called `Result::unwrap()` on an `Err` value: ExistentialMismatch(ExpectedFound { expected: [Binder { value: Trait(ExistentialTraitRef("Trait"[[(), ()]])), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [()], term: (), .. }), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [()], term: (), .. }), bound_vars: [] }], found: [Binder { value: Trait(ExistentialTraitRef("Trait"[[(), ?19t]])), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [?19t], term: ?19t, .. }), bound_vars: [] }, Binder { value: Projection(ExistentialProjection { def_id: TypeAliasId("Assoc"), args: [()], term: (), .. }), bound_vars: [] }] })
exprs: 0, ??ty: 0 (100%), ?ty: 0 (100%), !ty: 0
pats: 0, ??ty: 0 (100%), ?ty: 0 (100%), !ty: 0
panics: 1
Inference: 369.55ms, 1306minstr, 40mb
1/1 100% mir lowering: dummy::main2026-07-16T07:25:08.715840537+02:00 WARN Propagating panic for cycle head that panicked in an earlier execution in that revision
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the panic with the supplied Rust snippet and RUST_BACKTRACE=full rust-analyzer analysis-stats . --run-all-ide-things. Start at canonical::unify_query_var_values and the infer::coerce path shown in the backtrace. Done means inference handles this existential mismatch without panicking, with regression coverage for the example.
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