Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/project-model/src/cargo_workspace.rs')
-rw-r--r--crates/project-model/src/cargo_workspace.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs
index ff7cf144aa..9955f2687c 100644
--- a/crates/project-model/src/cargo_workspace.rs
+++ b/crates/project-model/src/cargo_workspace.rs
@@ -32,6 +32,7 @@ pub struct CargoWorkspace {
targets: Arena<TargetData>,
workspace_root: AbsPathBuf,
target_directory: AbsPathBuf,
+ manifest_path: ManifestPath,
}
impl ops::Index<Package> for CargoWorkspace {
@@ -306,7 +307,7 @@ impl CargoWorkspace {
);
}
// The manifest is a rust file, so this means its a script manifest
- if cargo_toml.extension().is_some_and(|ext| ext == "rs") {
+ if cargo_toml.is_rust_manifest() {
// Deliberately don't set up RUSTC_BOOTSTRAP or a nightly override here, the user should
// opt into it themselves.
other_options.push("-Zscript".to_owned());
@@ -334,7 +335,7 @@ impl CargoWorkspace {
.with_context(|| format!("Failed to run `{:?}`", meta.cargo_command()))
}
- pub fn new(mut meta: cargo_metadata::Metadata) -> CargoWorkspace {
+ pub fn new(mut meta: cargo_metadata::Metadata, manifest_path: ManifestPath) -> CargoWorkspace {
let mut pkg_by_id = FxHashMap::default();
let mut packages = Arena::default();
let mut targets = Arena::default();
@@ -448,7 +449,7 @@ impl CargoWorkspace {
let target_directory = AbsPathBuf::assert(meta.target_directory);
- CargoWorkspace { packages, targets, workspace_root, target_directory }
+ CargoWorkspace { packages, targets, workspace_root, target_directory, manifest_path }
}
pub fn packages(&self) -> impl ExactSizeIterator<Item = Package> + '_ {
@@ -466,6 +467,10 @@ impl CargoWorkspace {
&self.workspace_root
}
+ pub fn manifest_path(&self) -> &ManifestPath {
+ &self.manifest_path
+ }
+
pub fn target_directory(&self) -> &AbsPath {
&self.target_directory
}