diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-23 18:06:49 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-23 18:06:49 +0100 |
commit | 15ad78c638457e6ea95553e5d233c79e52bacb3b (patch) | |
tree | 151555d84672f020f79eb4cf34bb5e67ec106615 /crates/ra_project_model/src/project_json.rs | |
parent | 243b997df4dfc07910d38022828bc0f1d4745c57 (diff) | |
parent | 7c0743293e5720a5be7b44b4a781b2982d63152a (diff) |
Merge #5507
5507: Require quotes around key-value cfg flags in rust-project.json r=matklad a=matklad
This matches rustc command-line flags, as well as the build.rs format.
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_project_model/src/project_json.rs')
-rw-r--r-- | crates/ra_project_model/src/project_json.rs | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/crates/ra_project_model/src/project_json.rs b/crates/ra_project_model/src/project_json.rs index e9a333191..e3f3163f6 100644 --- a/crates/ra_project_model/src/project_json.rs +++ b/crates/ra_project_model/src/project_json.rs | |||
@@ -3,11 +3,11 @@ | |||
3 | use std::path::PathBuf; | 3 | use std::path::PathBuf; |
4 | 4 | ||
5 | use paths::{AbsPath, AbsPathBuf}; | 5 | use paths::{AbsPath, AbsPathBuf}; |
6 | use ra_cfg::CfgOptions; | ||
7 | use ra_db::{CrateId, CrateName, Dependency, Edition}; | 6 | use ra_db::{CrateId, CrateName, Dependency, Edition}; |
8 | use rustc_hash::{FxHashMap, FxHashSet}; | 7 | use rustc_hash::FxHashMap; |
9 | use serde::{de, Deserialize}; | 8 | use serde::{de, Deserialize}; |
10 | use stdx::split_delim; | 9 | |
10 | use crate::cfg_flag::CfgFlag; | ||
11 | 11 | ||
12 | /// Roots and crates that compose this Rust project. | 12 | /// Roots and crates that compose this Rust project. |
13 | #[derive(Clone, Debug, Eq, PartialEq)] | 13 | #[derive(Clone, Debug, Eq, PartialEq)] |
@@ -22,7 +22,7 @@ pub struct Crate { | |||
22 | pub(crate) root_module: AbsPathBuf, | 22 | pub(crate) root_module: AbsPathBuf, |
23 | pub(crate) edition: Edition, | 23 | pub(crate) edition: Edition, |
24 | pub(crate) deps: Vec<Dependency>, | 24 | pub(crate) deps: Vec<Dependency>, |
25 | pub(crate) cfg: CfgOptions, | 25 | pub(crate) cfg: Vec<CfgFlag>, |
26 | pub(crate) target: Option<String>, | 26 | pub(crate) target: Option<String>, |
27 | pub(crate) env: FxHashMap<String, String>, | 27 | pub(crate) env: FxHashMap<String, String>, |
28 | pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>, | 28 | pub(crate) proc_macro_dylib_path: Option<AbsPathBuf>, |
@@ -65,18 +65,7 @@ impl ProjectJson { | |||
65 | name: dep_data.name, | 65 | name: dep_data.name, |
66 | }) | 66 | }) |
67 | .collect::<Vec<_>>(), | 67 | .collect::<Vec<_>>(), |
68 | cfg: { | 68 | cfg: crate_data.cfg, |
69 | let mut cfg = CfgOptions::default(); | ||
70 | for entry in &crate_data.cfg { | ||
71 | match split_delim(entry, '=') { | ||
72 | Some((key, value)) => { | ||
73 | cfg.insert_key_value(key.into(), value.into()); | ||
74 | } | ||
75 | None => cfg.insert_atom(entry.into()), | ||
76 | } | ||
77 | } | ||
78 | cfg | ||
79 | }, | ||
80 | target: crate_data.target, | 69 | target: crate_data.target, |
81 | env: crate_data.env, | 70 | env: crate_data.env, |
82 | proc_macro_dylib_path: crate_data | 71 | proc_macro_dylib_path: crate_data |
@@ -103,7 +92,7 @@ struct CrateData { | |||
103 | edition: EditionData, | 92 | edition: EditionData, |
104 | deps: Vec<DepData>, | 93 | deps: Vec<DepData>, |
105 | #[serde(default)] | 94 | #[serde(default)] |
106 | cfg: FxHashSet<String>, | 95 | cfg: Vec<CfgFlag>, |
107 | target: Option<String>, | 96 | target: Option<String>, |
108 | #[serde(default)] | 97 | #[serde(default)] |
109 | env: FxHashMap<String, String>, | 98 | env: FxHashMap<String, String>, |