Unnamed repository; edit this file 'description' to name the repository.
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
Lukas Wirth 5 months ago
parent 762b21c · parent 85fcca6 · commit 4a2b38f
-rw-r--r--crates/project-model/src/workspace.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs
index 4d56668cf2..e02891eca2 100644
--- a/crates/project-model/src/workspace.rs
+++ b/crates/project-model/src/workspace.rs
@@ -819,10 +819,16 @@ impl ProjectWorkspace {
// [lib]
// path = "../../src/lib.rs"
// ```
+ //
+ // or
+ //
+ // ```toml
+ // [[bin]]
+ // path = "../bin_folder/main.rs"
+ // ```
let extra_targets = cargo[pkg]
.targets
.iter()
- .filter(|&&tgt| matches!(cargo[tgt].kind, TargetKind::Lib { .. }))
.filter_map(|&tgt| cargo[tgt].root.parent())
.map(|tgt| tgt.normalize().to_path_buf())
.filter(|path| !path.starts_with(&pkg_root));
@@ -838,6 +844,8 @@ impl ProjectWorkspace {
exclude.push(pkg_root.join("examples"));
exclude.push(pkg_root.join("benches"));
}
+ include.sort();
+ include.dedup();
PackageRoot { is_local, include, exclude }
})
.chain(mk_sysroot())
@@ -874,10 +882,16 @@ impl ProjectWorkspace {
// [lib]
// path = "../../src/lib.rs"
// ```
+ //
+ // or
+ //
+ // ```toml
+ // [[bin]]
+ // path = "../bin_folder/main.rs"
+ // ```
let extra_targets = cargo[pkg]
.targets
.iter()
- .filter(|&&tgt| matches!(cargo[tgt].kind, TargetKind::Lib { .. }))
.filter_map(|&tgt| cargo[tgt].root.parent())
.map(|tgt| tgt.normalize().to_path_buf())
.filter(|path| !path.starts_with(&pkg_root));
@@ -893,6 +907,8 @@ impl ProjectWorkspace {
exclude.push(pkg_root.join("examples"));
exclude.push(pkg_root.join("benches"));
}
+ include.sort();
+ include.dedup();
PackageRoot { is_local, include, exclude }
})
}))