Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/project-model/src/workspace.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index 1a138b17ba..5e06010c67 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -1091,6 +1091,24 @@ fn cargo_to_crate_graph(
continue;
}
+ // If the dependency is a dev-dependency with both crates being member libraries of
+ // the workspace we discard the edge. The reason can be read up on in
+ // https://github.com/rust-lang/rust-analyzer/issues/14167
+ // but in short, such an edge usually causes some form of cycle in the crate graph
+ // wrt to unit tests. Something we cannot reasonable support.
+ if dep.kind == DepKind::Dev
+ && matches!(kind, TargetKind::Lib { .. })
+ && cargo[dep.pkg].is_member
+ && cargo[pkg].is_member
+ {
+ tracing::warn!(
+ "Discarding dev-dependency edge from library target `{}` to library target `{}` to prevent potential cycles",
+ cargo[dep.pkg].name,
+ cargo[pkg].name
+ );
+ continue;
+ }
+
add_dep(crate_graph, from, name.clone(), to)
}
}