Skip to content

Commit 22ea559

Browse files
author
Jonas Schievink
committed
Don't load auxiliary crates outside the workspace
1 parent ac8806d commit 22ea559

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/project_model/src/workspace.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,15 @@ fn cargo_to_crate_graph(
574574
has_private |= cargo[pkg].metadata.rustc_private;
575575
let mut lib_tgt = None;
576576
for &tgt in cargo[pkg].targets.iter() {
577+
if cargo[tgt].kind != TargetKind::Lib && !cargo[pkg].is_member {
578+
// For non-workspace-members, Cargo does not resolve dev-dependencies, so we don't
579+
// add any targets except the library target, since those will not work correctly if
580+
// they use dev-dependencies.
581+
// In fact, they can break quite badly if multiple client workspaces get merged:
582+
// https://github.com/rust-analyzer/rust-analyzer/issues/11300
583+
continue;
584+
}
585+
577586
if let Some(file_id) = load(&cargo[tgt].root) {
578587
let crate_id = add_target_crate_root(
579588
&mut crate_graph,

0 commit comments

Comments
 (0)