about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crates/project_model/src/workspace.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs
index 869b064e1da..96522bf070a 100644
--- a/crates/project_model/src/workspace.rs
+++ b/crates/project_model/src/workspace.rs
@@ -574,6 +574,15 @@ fn cargo_to_crate_graph(
         has_private |= cargo[pkg].metadata.rustc_private;
         let mut lib_tgt = None;
         for &tgt in cargo[pkg].targets.iter() {
+            if cargo[tgt].kind != TargetKind::Lib && !cargo[pkg].is_member {
+                // For non-workspace-members, Cargo does not resolve dev-dependencies, so we don't
+                // add any targets except the library target, since those will not work correctly if
+                // they use dev-dependencies.
+                // In fact, they can break quite badly if multiple client workspaces get merged:
+                // https://github.com/rust-analyzer/rust-analyzer/issues/11300
+                continue;
+            }
+
             if let Some(file_id) = load(&cargo[tgt].root) {
                 let crate_id = add_target_crate_root(
                     &mut crate_graph,