diff options
Diffstat (limited to 'crates/project_model')
-rw-r--r-- | crates/project_model/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/project_model/src/cargo_workspace.rs | 23 | ||||
-rw-r--r-- | crates/project_model/src/project_json.rs | 3 |
3 files changed, 26 insertions, 2 deletions
diff --git a/crates/project_model/Cargo.toml b/crates/project_model/Cargo.toml index c55e85709..a65e42261 100644 --- a/crates/project_model/Cargo.toml +++ b/crates/project_model/Cargo.toml | |||
@@ -16,7 +16,7 @@ cargo_metadata = "=0.12.0" | |||
16 | serde = { version = "1.0.106", features = ["derive"] } | 16 | serde = { version = "1.0.106", features = ["derive"] } |
17 | serde_json = "1.0.48" | 17 | serde_json = "1.0.48" |
18 | anyhow = "1.0.26" | 18 | anyhow = "1.0.26" |
19 | itertools = "0.9.0" | 19 | itertools = "0.10.0" |
20 | 20 | ||
21 | arena = { path = "../arena", version = "0.0.0" } | 21 | arena = { path = "../arena", version = "0.0.0" } |
22 | cfg = { path = "../cfg", version = "0.0.0" } | 22 | cfg = { path = "../cfg", version = "0.0.0" } |
diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index bb3b6f2ef..1700cb8a7 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs | |||
@@ -1,6 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use std::{ | 3 | use std::{ |
4 | convert::TryInto, | ||
4 | ffi::OsStr, | 5 | ffi::OsStr, |
5 | ops, | 6 | ops, |
6 | path::{Path, PathBuf}, | 7 | path::{Path, PathBuf}, |
@@ -196,8 +197,23 @@ impl CargoWorkspace { | |||
196 | if let Some(target) = target { | 197 | if let Some(target) = target { |
197 | meta.other_options(vec![String::from("--filter-platform"), target]); | 198 | meta.other_options(vec![String::from("--filter-platform"), target]); |
198 | } | 199 | } |
200 | |||
199 | let mut meta = meta.exec().with_context(|| { | 201 | let mut meta = meta.exec().with_context(|| { |
200 | format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) | 202 | let cwd: Option<AbsPathBuf> = |
203 | std::env::current_dir().ok().and_then(|p| p.try_into().ok()); | ||
204 | |||
205 | let workdir = cargo_toml | ||
206 | .parent() | ||
207 | .map(|p| p.to_path_buf()) | ||
208 | .or(cwd) | ||
209 | .map(|dir| dir.to_string_lossy().to_string()) | ||
210 | .unwrap_or_else(|| "<failed to get path>".into()); | ||
211 | |||
212 | format!( | ||
213 | "Failed to run `cargo metadata --manifest-path {}` in `{}`", | ||
214 | cargo_toml.display(), | ||
215 | workdir | ||
216 | ) | ||
201 | })?; | 217 | })?; |
202 | 218 | ||
203 | let mut out_dir_by_id = FxHashMap::default(); | 219 | let mut out_dir_by_id = FxHashMap::default(); |
@@ -334,6 +350,11 @@ pub(crate) fn load_extern_resources( | |||
334 | let mut cmd = Command::new(toolchain::cargo()); | 350 | let mut cmd = Command::new(toolchain::cargo()); |
335 | cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); | 351 | cmd.args(&["check", "--message-format=json", "--manifest-path"]).arg(cargo_toml); |
336 | 352 | ||
353 | // --all-targets includes tests, benches and examples in addition to the | ||
354 | // default lib and bins. This is an independent concept from the --targets | ||
355 | // flag below. | ||
356 | cmd.arg("--all-targets"); | ||
357 | |||
337 | if let Some(target) = &cargo_features.target { | 358 | if let Some(target) = &cargo_features.target { |
338 | cmd.args(&["--target", target]); | 359 | cmd.args(&["--target", target]); |
339 | } | 360 | } |
diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index aab279223..af884eb84 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs | |||
@@ -139,6 +139,8 @@ enum EditionData { | |||
139 | Edition2015, | 139 | Edition2015, |
140 | #[serde(rename = "2018")] | 140 | #[serde(rename = "2018")] |
141 | Edition2018, | 141 | Edition2018, |
142 | #[serde(rename = "2021")] | ||
143 | Edition2021, | ||
142 | } | 144 | } |
143 | 145 | ||
144 | impl From<EditionData> for Edition { | 146 | impl From<EditionData> for Edition { |
@@ -146,6 +148,7 @@ impl From<EditionData> for Edition { | |||
146 | match data { | 148 | match data { |
147 | EditionData::Edition2015 => Edition::Edition2015, | 149 | EditionData::Edition2015 => Edition::Edition2015, |
148 | EditionData::Edition2018 => Edition::Edition2018, | 150 | EditionData::Edition2018 => Edition::Edition2018, |
151 | EditionData::Edition2021 => Edition::Edition2021, | ||
149 | } | 152 | } |
150 | } | 153 | } |
151 | } | 154 | } |