diff options
author | Aleksey Kladov <[email protected]> | 2020-07-23 17:57:27 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-07-23 18:03:17 +0100 |
commit | 7c0743293e5720a5be7b44b4a781b2982d63152a (patch) | |
tree | 151555d84672f020f79eb4cf34bb5e67ec106615 /crates/ra_project_model/src/cargo_workspace.rs | |
parent | 243b997df4dfc07910d38022828bc0f1d4745c57 (diff) |
Require quotes around key-value cfg flags in rust-project.json
This matches rustc command-line flags, as well as the build.rs format.
Diffstat (limited to 'crates/ra_project_model/src/cargo_workspace.rs')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 4182ca156..fb88e0f06 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -14,6 +14,8 @@ use ra_arena::{Arena, Idx}; | |||
14 | use ra_db::Edition; | 14 | use ra_db::Edition; |
15 | use rustc_hash::FxHashMap; | 15 | use rustc_hash::FxHashMap; |
16 | 16 | ||
17 | use crate::cfg_flag::CfgFlag; | ||
18 | |||
17 | /// `CargoWorkspace` represents the logical structure of, well, a Cargo | 19 | /// `CargoWorkspace` represents the logical structure of, well, a Cargo |
18 | /// workspace. It pretty closely mirrors `cargo metadata` output. | 20 | /// workspace. It pretty closely mirrors `cargo metadata` output. |
19 | /// | 21 | /// |
@@ -78,7 +80,7 @@ pub struct PackageData { | |||
78 | pub dependencies: Vec<PackageDependency>, | 80 | pub dependencies: Vec<PackageDependency>, |
79 | pub edition: Edition, | 81 | pub edition: Edition, |
80 | pub features: Vec<String>, | 82 | pub features: Vec<String>, |
81 | pub cfgs: Vec<String>, | 83 | pub cfgs: Vec<CfgFlag>, |
82 | pub out_dir: Option<AbsPathBuf>, | 84 | pub out_dir: Option<AbsPathBuf>, |
83 | pub proc_macro_dylib_path: Option<AbsPathBuf>, | 85 | pub proc_macro_dylib_path: Option<AbsPathBuf>, |
84 | } | 86 | } |
@@ -276,7 +278,7 @@ impl CargoWorkspace { | |||
276 | pub struct ExternResources { | 278 | pub struct ExternResources { |
277 | out_dirs: FxHashMap<PackageId, AbsPathBuf>, | 279 | out_dirs: FxHashMap<PackageId, AbsPathBuf>, |
278 | proc_dylib_paths: FxHashMap<PackageId, AbsPathBuf>, | 280 | proc_dylib_paths: FxHashMap<PackageId, AbsPathBuf>, |
279 | cfgs: FxHashMap<PackageId, Vec<String>>, | 281 | cfgs: FxHashMap<PackageId, Vec<CfgFlag>>, |
280 | } | 282 | } |
281 | 283 | ||
282 | pub fn load_extern_resources( | 284 | pub fn load_extern_resources( |
@@ -303,6 +305,18 @@ pub fn load_extern_resources( | |||
303 | if let Ok(message) = message { | 305 | if let Ok(message) = message { |
304 | match message { | 306 | match message { |
305 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { | 307 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { |
308 | let cfgs = { | ||
309 | let mut acc = Vec::new(); | ||
310 | for cfg in cfgs { | ||
311 | match cfg.parse::<CfgFlag>() { | ||
312 | Ok(it) => acc.push(it), | ||
313 | Err(err) => { | ||
314 | anyhow::bail!("invalid cfg from cargo-metadata: {}", err) | ||
315 | } | ||
316 | }; | ||
317 | } | ||
318 | acc | ||
319 | }; | ||
306 | // cargo_metadata crate returns default (empty) path for | 320 | // cargo_metadata crate returns default (empty) path for |
307 | // older cargos, which is not absolute, so work around that. | 321 | // older cargos, which is not absolute, so work around that. |
308 | if out_dir != PathBuf::default() { | 322 | if out_dir != PathBuf::default() { |