{"id":"9b8aaf5e22785354","repo":"rust-lang/cargo","slug":"an-already-used-dep-now-pending","errorCode":null,"errorMessage":"an already used dep now pending!?","messagePattern":"an already used dep now pending!\\?","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/resolver/mod.rs","lineNumber":854,"sourceCode":"        return None;\n    }\n    // What parents does that critical activation have\n    for (critical_parent, critical_parents_deps) in\n        cx.parents.edges(&backtrack_critical_id).filter(|(p, _)| {\n            // it will only help backjump further if it is older then the critical_age\n            cx.is_active(**p).expect(\"parent not currently active!?\") < backtrack_critical_age\n        })\n    {\n        for critical_parents_dep in critical_parents_deps.iter() {\n            // We only want `first_version.is_some()` for direct dependencies of workspace\n            // members which isn't the case here as this has a `parent`\n            let first_version = None;\n            // A dep is equivalent to one of the things it can resolve to.\n            // Thus, if all the things it can resolve to have already ben determined\n            // to be conflicting, then we can just say that we conflict with the parent.\n            if let Some(others) = registry\n                .query(critical_parents_dep, first_version)\n                .expect(\"an already used dep now pending!?\")\n                .expect(\"an already used dep now error!?\")\n                .iter()\n                .rev() // the last one to be tried is the least likely to be in the cache, so start with that.\n                .map(|other| {\n                    past_conflicting_activations\n                        .find(\n                            dep,\n                            &|id| {\n                                if id == other.package_id() {\n                                    // we are imagining that we used other instead\n                                    Some(backtrack_critical_age)\n                                } else {\n                                    cx.is_active(id)\n                                }\n                            },\n                            Some(other.package_id()),\n                            // we only care about things that are newer then critical_age\n                            backtrack_critical_age,","sourceCodeStart":836,"sourceCodeEnd":872,"githubUrl":"https://github.com/rust-lang/cargo/blob/0e07a155371a6ce88ae53a2c00df940280c09a67/src/resolver/mod.rs#L836-L872","documentation":"Invariant adjacent to 318: `registry.query(critical_parents_dep, first_version).expect(\"an already used dep now pending!?\").expect(\"an already used dep now error!?\")`. During conflict-resolution, the resolver re-queries a dependency it believes was already resolved; it assumes the query cannot fail (pending) and cannot error.","triggerScenarios":"Fires if `registry.query` returns `Err` (the second expect) or a pending/`None` state (the first expect) for a dependency the resolver previously treated as resolved — indicating the registry/source state changed mid-resolution or a query bug.","commonSituations":"Cargo resolver bug surfaced on intricate graphs; a registry index updated mid-build (rare); a `[patch]`/`[replace]` whose query semantics changed between calls; a source-rewrite that returns different candidates for the same query. Users see it as a panic during dependency resolution.","solutions":["Report a cargo bug with the reproducer (`Cargo.toml`, lockfile, registry config).","Switch resolver version (`resolver = \"1\"`/`\"2\"`) or adjust `[patch]` to alter the query path.","Pin dependency versions to reduce backtracking and avoid the conflicting branch.","Update cargo and clear the registry index cache before retrying."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// No direct pre-check; sidestep by altering resolver/query inputs.\n// In Cargo.toml root:\n// [package]\n// resolver = \"2\"\n// And pin or relax the dependency that triggers repeated backtracking.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep `[patch]`/`[replace]` minimal and stable across builds.","Avoid registry index updates mid-build (run `cargo update` separately).","Pin cargo and report reproducers to the cargo team."],"tags":["cargo","panic","invariant","resolver","backtracking","registry-query","rust"],"analyzedSha":"0e07a155371a6ce88ae53a2c00df940280c09a67","analyzedAt":"2026-08-06T01:46:58.334Z","schemaVersion":2}