Cyclic dependency graph when parsing OPAQUE-KE v4.0.1
rust-analyzer version: rust-analyzer version: 0.3.2667-standalone (bacc5bbd30 2025-11-02)
rustc version: rustc 1.93.0-nightly (843f8ce2e 2025-11-07)
editor or extension: VSCode, extension version 0.3.2667
relevant settings: all empty
repository link (if public, optional): opaque-ke
code snippet to reproduce: Just add OPAQUE-KE v4.0.0 or v4.0.1 to Cargo.toml and you start to get the error. This does not happen if I downgrade rust-analyzer to the version 2025-08-25 v0.3.2593-standalone (6b2e677795 2025-08-25). It starts appearing since 2025-10-27 (v0.3.2658).
thread 'Worker2' (3552474) panicked at /rust/deps/salsa-0.24.0/src/function/fetch.rs:271:21:
dependency graph cycle when querying generic_predicates_shim(Id(9d95)), set cycle_fn/cycle_initial to fixpoint iterate.
Query stack:
[
infer_shim(Id(1457f)),
trait_impls_in_deps_shim(Id(70d3)),
trait_impls_in_crate_shim(Id(704d)),
impl_trait_with_diagnostics_shim(Id(176ce)),
impl_self_ty_with_diagnostics_shim(Id(176ce)),
type_for_type_alias_with_diagnostics_shim(Id(a1cc)),
generic_predicates_for_param_shim(Id(87035)),
generic_predicates_shim(Id(9d95)),
type_for_type_alias_with_diagnostics_shim(Id(a1cb)),
generic_predicates_for_param_shim(Id(87036)),
]
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: <salsa::function::IngredientImpl<hir_ty::db::create_data_HirDatabase::create_data_HirDatabase_Configuration_>>::fetch_cold_cycle::{closure#0}
3: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates::generic_predicates_shim::generic_predicates_shim_Configuration_>>::fetch_cold_cycle
4: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates::generic_predicates_shim::generic_predicates_shim_Configuration_>>::fetch_cold_with_retry
5: <_ as hir_ty::db::HirDatabase>::generic_predicates::generic_predicates_shim
6: <hir_ty::next_solver::interner::DbInterner as ra_ap_rustc_type_ir::interner::Interner>::explicit_super_predicates_of
7: ra_ap_rustc_type_ir::elaborate::supertrait_def_ids::<hir_ty::next_solver::interner::DbInterner>::{closure#0}
8: <<_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim::generic_predicates_for_param_shim_Configuration_ as salsa::function::Configuration>::execute
9: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim::generic_predicates_for_param_shim_Configuration_>>::execute
10: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim::generic_predicates_for_param_shim_Configuration_>>::fetch_cold_with_retry
11: <_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim
12: <hir_ty::lower::path::PathLoweringContext>::select_associated_type
13: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
14: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
15: hir_ty::lower::path::substs_from_args_and_bindings::<<hir_ty::lower::path::PathLoweringContext>::substs_from_args_and_bindings::LowererCtx>
16: <hir_ty::lower::path::PathLoweringContext>::substs_from_path_segment
17: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
18: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
19: <<_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim::type_for_type_alias_with_diagnostics_shim_Configuration_ as salsa::function::Configuration>::execute
20: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim::type_for_type_alias_with_diagnostics_shim_Configuration_>>::execute
21: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim::type_for_type_alias_with_diagnostics_shim_Configuration_>>::fetch_cold_with_retry
22: <_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim
23: hir_ty::lower::ty_query
24: <hir_ty::lower::path::PathLoweringContext>::lower_path_inner
25: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
26: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
27: <hir_ty::lower::TyLoweringContext>::lower_where_predicate
28: hir_ty::lower::generic_predicates_filtered_by::<hir_ty::lower::generic_predicates_query::{closure#0}>
29: <<_ as hir_ty::db::HirDatabase>::generic_predicates::generic_predicates_shim::generic_predicates_shim_Configuration_ as salsa::function::Configuration>::execute
30: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates::generic_predicates_shim::generic_predicates_shim_Configuration_>>::execute
31: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates::generic_predicates_shim::generic_predicates_shim_Configuration_>>::fetch_cold_with_retry
32: <_ as hir_ty::db::HirDatabase>::generic_predicates::generic_predicates_shim
33: <hir_ty::next_solver::interner::DbInterner as ra_ap_rustc_type_ir::interner::Interner>::explicit_super_predicates_of
34: ra_ap_rustc_type_ir::elaborate::supertrait_def_ids::<hir_ty::next_solver::interner::DbInterner>::{closure#0}
35: <<_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim::generic_predicates_for_param_shim_Configuration_ as salsa::function::Configuration>::execute
36: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim::generic_predicates_for_param_shim_Configuration_>>::execute
37: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim::generic_predicates_for_param_shim_Configuration_>>::fetch_cold_with_retry
38: <_ as hir_ty::db::HirDatabase>::generic_predicates_for_param::generic_predicates_for_param_shim
39: <hir_ty::lower::path::PathLoweringContext>::select_associated_type
40: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
41: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
42: hir_ty::lower::path::substs_from_args_and_bindings::<<hir_ty::lower::path::PathLoweringContext>::substs_from_args_and_bindings::LowererCtx>
43: <hir_ty::lower::path::PathLoweringContext>::substs_from_path_segment
44: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
45: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
46: <<_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim::type_for_type_alias_with_diagnostics_shim_Configuration_ as salsa::function::Configuration>::execute
47: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim::type_for_type_alias_with_diagnostics_shim_Configuration_>>::execute
48: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim::type_for_type_alias_with_diagnostics_shim_Configuration_>>::fetch_cold_with_retry
49: <_ as hir_ty::db::HirDatabase>::type_for_type_alias_with_diagnostics::type_for_type_alias_with_diagnostics_shim
50: hir_ty::lower::ty_query
51: <hir_ty::lower::path::PathLoweringContext>::lower_path_inner
52: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
53: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
54: <<hir_ty::lower::path::PathLoweringContext>::substs_from_args_and_bindings::LowererCtx as hir_ty::lower::path::GenericArgsLowerer>::provided_kind
55: hir_ty::lower::path::substs_from_args_and_bindings::<<hir_ty::lower::path::PathLoweringContext>::substs_from_args_and_bindings::LowererCtx>
56: <hir_ty::lower::path::PathLoweringContext>::substs_from_path_segment
57: <hir_ty::lower::path::PathLoweringContext>::lower_path_inner
58: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
59: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
60: <<hir_ty::lower::path::PathLoweringContext>::substs_from_args_and_bindings::LowererCtx as hir_ty::lower::path::GenericArgsLowerer>::provided_kind
61: hir_ty::lower::path::substs_from_args_and_bindings::<<hir_ty::lower::path::PathLoweringContext>::substs_from_args_and_bindings::LowererCtx>
62: <hir_ty::lower::path::PathLoweringContext>::substs_from_path_segment
63: <hir_ty::lower::path::PathLoweringContext>::lower_path_inner
64: <hir_ty::lower::path::PathLoweringContext>::lower_partly_resolved_path
65: <hir_ty::lower::TyLoweringContext>::lower_ty_ext
66: <<_ as hir_ty::db::HirDatabase>::impl_self_ty_with_diagnostics::impl_self_ty_with_diagnostics_shim::impl_self_ty_with_diagnostics_shim_Configuration_ as salsa::function::Configuration>::execute
67: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::impl_self_ty_with_diagnostics::impl_self_ty_with_diagnostics_shim::impl_self_ty_with_diagnostics_shim_Configuration_>>::execute
68: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::impl_self_ty_with_diagnostics::impl_self_ty_with_diagnostics_shim::impl_self_ty_with_diagnostics_shim_Configuration_>>::fetch_cold_with_retry
69: <_ as hir_ty::db::HirDatabase>::impl_self_ty_with_diagnostics::impl_self_ty_with_diagnostics_shim
70: <ide_db::RootDatabase as hir_ty::db::HirDatabase>::impl_self_ty
71: <<_ as hir_ty::db::HirDatabase>::impl_trait_with_diagnostics::impl_trait_with_diagnostics_shim::impl_trait_with_diagnostics_shim_Configuration_ as salsa::function::Configuration>::execute
72: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::impl_trait_with_diagnostics::impl_trait_with_diagnostics_shim::impl_trait_with_diagnostics_shim_Configuration_>>::execute
73: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::impl_trait_with_diagnostics::impl_trait_with_diagnostics_shim::impl_trait_with_diagnostics_shim_Configuration_>>::fetch_cold_with_retry
74: <_ as hir_ty::db::HirDatabase>::impl_trait_with_diagnostics::impl_trait_with_diagnostics_shim
75: <ide_db::RootDatabase as hir_ty::db::HirDatabase>::impl_trait
76: <hir_ty::method_resolution::TraitImpls>::collect_def_map
77: <<_ as hir_ty::db::HirDatabase>::trait_impls_in_crate::trait_impls_in_crate_shim::trait_impls_in_crate_shim_Configuration_ as salsa::function::Configuration>::execute
78: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::trait_impls_in_crate::trait_impls_in_crate_shim::trait_impls_in_crate_shim_Configuration_>>::execute
79: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::trait_impls_in_crate::trait_impls_in_crate_shim::trait_impls_in_crate_shim_Configuration_>>::fetch_cold_with_retry
80: <_ as hir_ty::db::HirDatabase>::trait_impls_in_crate::trait_impls_in_crate_shim
81: <<_ as hir_ty::db::HirDatabase>::trait_impls_in_deps::trait_impls_in_deps_shim::trait_impls_in_deps_shim_Configuration_ as salsa::function::Configuration>::execute
82: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::trait_impls_in_deps::trait_impls_in_deps_shim::trait_impls_in_deps_shim_Configuration_>>::execute
83: <salsa::function::IngredientImpl<<_ as hir_ty::db::HirDatabase>::trait_impls_in_deps::trait_impls_in_deps_shim::trait_impls_in_deps_shim_Configuration_>>::fetch_cold_with_retry
84: <_ as hir_ty::db::HirDatabase>::trait_impls_in_deps::trait_impls_in_deps_shim
85: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::compute_trait_goal
86: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::compute_goal
87: <ra_ap_rustc_type_ir::search_graph::SearchGraph<ra_ap_rustc_next_trait_solver::solve::search_graph::SearchGraphDelegate<hir_ty::next_solver::solver::SolverContext>, hir_ty::next_solver::interner::DbInterner>>::evaluate_goal_in_task
88: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::evaluate_goal_raw
89: <ra_ap_rustc_next_trait_solver::solve::eval_ctxt::EvalCtxt<hir_ty::next_solver::solver::SolverContext, hir_ty::next_solver::interner::DbInterner>>::evaluate_goal
90: <hir_ty::next_solver::solver::SolverContext as ra_ap_rustc_next_trait_solver::solve::eval_ctxt::SolverDelegateEvalExt>::evaluate_root_goal
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
query stacktrace:
0: generic_predicates_for_param_shim(Id(87036)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
1: type_for_type_alias_with_diagnostics_shim(Id(a1cb)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
2: generic_predicates_shim(Id(9d95)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
3: generic_predicates_for_param_shim(Id(87035)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
4: type_for_type_alias_with_diagnostics_shim(Id(a1cc)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
5: impl_self_ty_with_diagnostics_shim(Id(176ce)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
6: impl_trait_with_diagnostics_shim(Id(176ce)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
7: trait_impls_in_crate_shim(Id(704d)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
8: trait_impls_in_deps_shim(Id(70d3)) -> (R20194, Durability::MEDIUM)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
9: infer_shim(Id(1457f)) -> (R20194, Durability::LOW)
at src/tools/rust-analyzer/crates/hir-ty/src/db.rs:28
additional context:
0:
version: 1.93.0-nightly (843f8ce2 2025-11-07)
request: textDocument/semanticTokens/full/delta SemanticTokensDeltaParams {
work_done_progress_params: WorkDoneProgressParams {
work_done_token: None,
},
partial_result_params: PartialResultParams {
partial_result_token: None,
},
text_document: TextDocumentIdentifier {
uri: Url {
scheme: "file",
cannot_be_a_base: false,
username: "",
password: None,
host: None,
port: None,
path: "/src/registration/signup.rs",
query: None,
fragment: None,
},
},
previous_result_id: "1",
}
[Error - 7:04:49 AM] Request textDocument/semanticTokens/full/delta failed.
Message: request handler panicked: dependency graph cycle when querying generic_predicates_shim(Id(9d95)), set cycle_fn/cycle_initial to fixpoint iterate.
Query stack:
[
infer_shim(Id(1457f)),
trait_impls_in_deps_shim(Id(70d3)),
trait_impls_in_crate_shim(Id(704d)),
impl_trait_with_diagnostics_shim(Id(176ce)),
impl_self_ty_with_diagnostics_shim(Id(176ce)),
type_for_type_alias_with_diagnostics_shim(Id(a1cc)),
generic_predicates_for_param_shim(Id(87035)),
generic_predicates_shim(Id(9d95)),
type_for_type_alias_with_diagnostics_shim(Id(a1cb)),
generic_predicates_for_param_shim(Id(87036)),
]
Code: -32603
@rustbot claim
In commit 50384460c6, the GenericPredicates::query_with_diagnostics method was converted to a salsa tracked query but the cycle handler was not added during the conversion.
I met the same problem when I used rust-analyzer in neovim when parsing the same version of opaque-ke.
OK, I have a minimal standalone repro.
trait VCipherSuite {}
trait CipherSuite
where
OprfHash<Self>: Hash,
{
}
type Bar<CS: CipherSuite> = <CS::Baz as VCipherSuite>::Hash;
type OprfHash<CS: CipherSuite> = <CS::Baz as VCipherSuite>::Hash;
impl<CS: CipherSuite> Foo<CS> {
fn seal() {}
}
Put this in a lib.rs and run rust-analyzer analysis-stats . to get the error:
thread 'main' (13941245) panicked at /Users/wilfred/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/salsa-0.24.0/src/function/fetch.rs:271:21:
dependency graph cycle when querying GenericPredicates < 'db >::query_with_diagnostics_(Id(7d96)), set cycle_fn/cycle_initial to fixpoint iterate.
Query stack:
[
InferenceResult < 'db >::for_body_(Id(1500b)),
trait_environment_shim(Id(1500b)),
GenericPredicates < 'db >::query_with_diagnostics_(Id(7d96)),
type_for_type_alias_with_diagnostics_shim(Id(81c4)),
generic_predicates_for_param(Id(20011)),
trait_signature_with_source_map_shim(Id(7d95)),
VariantFields::firewall_(Id(840a)),
VariantFields::query_(Id(840a)),
VariantFields::firewall_(Id(8749)),
VariantFields::query_(Id(8749)),
]
stack backtrace:
0: __rustc::rust_begin_unwind
1: core::panicking::panic_fmt
2: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold_cycle::{{closure}}
3: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold_cycle
4: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch_cold_with_retry
5: salsa::function::fetch::<impl salsa::function::IngredientImpl<C>>::fetch
6: std::thread::local::LocalKey<T>::with
7: <hir_ty::next_solver::interner::DbInterner as ra_ap_rustc_type_ir::interner::Interner>::explicit_super_predicates_of
...
I'm not sure if this is a lowering issue (as suggested by @ChayimFriedman2 on #21117) or a salsa issue.
Woah, thanks! I don't believe this can be a Salsa issue, and this likely is a lowering problem, as rustc does not cycle on this code.
@Aditya-PS-05, are you still interested in this?
The reason for the cycle is these lines:
https://github.com/rust-lang/rust-analyzer/blob/34fd9f65a3a1faa7d3a55090ed877530b464998d/crates/hir-ty/src/lower.rs#L1569-L1573
supertrait_def_ids() calls explicit_super_predicates_of() which calls GenericPredicates::query(), something not allowed in generic_predicates_for_params(). In rustc this is good since explicit_super_predicates_of() is its own query which only lowers generic parameters on Self; what we need to do is to call generic_predicates_for_params() on Self (unless we're computing it) and get the supertraits from there instead.