diff options
author | oxalica <[email protected]> | 2019-10-05 13:55:27 +0100 |
---|---|---|
committer | oxalica <[email protected]> | 2019-10-05 13:55:27 +0100 |
commit | c6303d9fee98232ac83a77f943c39d65c9c6b6db (patch) | |
tree | 9c0f29993289916e3cc43d7be9cfa6f0a62b7754 /crates/ra_project_model/src/lib.rs | |
parent | b271cb18d5ab19624e751867df6705cd1e94edbc (diff) |
Use raw cfgs in json project and fix typo
Diffstat (limited to 'crates/ra_project_model/src/lib.rs')
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 05e49f5ce..640a5ebd3 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -134,11 +134,13 @@ impl ProjectWorkspace { | |||
134 | json_project::Edition::Edition2015 => Edition::Edition2015, | 134 | json_project::Edition::Edition2015 => Edition::Edition2015, |
135 | json_project::Edition::Edition2018 => Edition::Edition2018, | 135 | json_project::Edition::Edition2018 => Edition::Edition2018, |
136 | }; | 136 | }; |
137 | // FIXME: cfg options | 137 | let mut cfg_options = default_cfg_options.clone(); |
138 | // Default to enable test for workspace crates. | 138 | for name in &krate.atom_cfgs { |
139 | let cfg_options = default_cfg_options | 139 | cfg_options = cfg_options.atom(name.into()); |
140 | .clone() | 140 | } |
141 | .features(krate.features.iter().map(Into::into)); | 141 | for (key, value) in &krate.key_value_cfgs { |
142 | cfg_options = cfg_options.key_value(key.into(), value.into()); | ||
143 | } | ||
142 | crates.insert( | 144 | crates.insert( |
143 | crate_id, | 145 | crate_id, |
144 | crate_graph.add_crate_root(file_id, edition, cfg_options), | 146 | crate_graph.add_crate_root(file_id, edition, cfg_options), |
@@ -309,7 +311,7 @@ pub fn get_rustc_cfg_options() -> CfgOptions { | |||
309 | let mut cfg_options = CfgOptions::default(); | 311 | let mut cfg_options = CfgOptions::default(); |
310 | 312 | ||
311 | match (|| -> Result<_> { | 313 | match (|| -> Result<_> { |
312 | // `cfg(test)` ans `cfg(debug_assertion)` is handled outside, so we suppress them here. | 314 | // `cfg(test)` and `cfg(debug_assertion)` are handled outside, so we suppress them here. |
313 | let output = Command::new("rustc").args(&["--print", "cfg", "-O"]).output()?; | 315 | let output = Command::new("rustc").args(&["--print", "cfg", "-O"]).output()?; |
314 | if !output.status.success() { | 316 | if !output.status.success() { |
315 | Err("failed to get rustc cfgs")?; | 317 | Err("failed to get rustc cfgs")?; |