Skip to content

Commit 4a2b38f

Browse files
authored
Merge pull request #21098 from Aditya-PS-05/fix/include-bin-targets-outside-pkg-root
fix: include all target types with paths outside package root
2 parents 762b21c + 85fcca6 commit 4a2b38f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

crates/project-model/src/workspace.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,10 +819,16 @@ impl ProjectWorkspace {
819819
// [lib]
820820
// path = "../../src/lib.rs"
821821
// ```
822+
//
823+
// or
824+
//
825+
// ```toml
826+
// [[bin]]
827+
// path = "../bin_folder/main.rs"
828+
// ```
822829
let extra_targets = cargo[pkg]
823830
.targets
824831
.iter()
825-
.filter(|&&tgt| matches!(cargo[tgt].kind, TargetKind::Lib { .. }))
826832
.filter_map(|&tgt| cargo[tgt].root.parent())
827833
.map(|tgt| tgt.normalize().to_path_buf())
828834
.filter(|path| !path.starts_with(&pkg_root));
@@ -838,6 +844,8 @@ impl ProjectWorkspace {
838844
exclude.push(pkg_root.join("examples"));
839845
exclude.push(pkg_root.join("benches"));
840846
}
847+
include.sort();
848+
include.dedup();
841849
PackageRoot { is_local, include, exclude }
842850
})
843851
.chain(mk_sysroot())
@@ -874,10 +882,16 @@ impl ProjectWorkspace {
874882
// [lib]
875883
// path = "../../src/lib.rs"
876884
// ```
885+
//
886+
// or
887+
//
888+
// ```toml
889+
// [[bin]]
890+
// path = "../bin_folder/main.rs"
891+
// ```
877892
let extra_targets = cargo[pkg]
878893
.targets
879894
.iter()
880-
.filter(|&&tgt| matches!(cargo[tgt].kind, TargetKind::Lib { .. }))
881895
.filter_map(|&tgt| cargo[tgt].root.parent())
882896
.map(|tgt| tgt.normalize().to_path_buf())
883897
.filter(|path| !path.starts_with(&pkg_root));
@@ -893,6 +907,8 @@ impl ProjectWorkspace {
893907
exclude.push(pkg_root.join("examples"));
894908
exclude.push(pkg_root.join("benches"));
895909
}
910+
include.sort();
911+
include.dedup();
896912
PackageRoot { is_local, include, exclude }
897913
})
898914
}))

0 commit comments

Comments
 (0)