Skip to content

Commit c32be4b

Browse files
committed
Ignore illform node id from metadata
1 parent 912776f commit c32be4b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

crates/ra_project_model/src/cargo_workspace.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,25 @@ impl CargoWorkspace {
207207
}
208208
let resolve = meta.resolve.expect("metadata executed with deps");
209209
for node in resolve.nodes {
210-
let source = pkg_by_id[&node.id];
210+
let source = match pkg_by_id.get(&node.id) {
211+
Some(&src) => src,
212+
None => {
213+
log::error!("Node id do not match in cargo metadata, ignoring {}", node.id);
214+
continue;
215+
}
216+
};
211217
for dep_node in node.deps {
212-
let dep = PackageDependency { name: dep_node.name, pkg: pkg_by_id[&dep_node.pkg] };
218+
let pkg = match pkg_by_id.get(&dep_node.pkg) {
219+
Some(&pkg) => pkg,
220+
None => {
221+
log::error!(
222+
"Dep node id do not match in cargo metadata, ignoring {}",
223+
dep_node.pkg
224+
);
225+
continue;
226+
}
227+
};
228+
let dep = PackageDependency { name: dep_node.name, pkg };
213229
packages[source].dependencies.push(dep);
214230
}
215231
packages[source].features.extend(node.features);

0 commit comments

Comments
 (0)