aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-07 15:29:03 +0100
committerPaul Daniel Faria <[email protected]>2020-06-07 15:29:03 +0100
commit3937b225e7918ae6d75849a0959754af43fbf08c (patch)
treeedcf3d514f87a8772fa5c97aae2a58e5ddcb7b35 /crates
parentdc340f12a39e7cd8b495b84c009052c4d441d867 (diff)
Change management of test cfg to better support json projects
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_project_model/src/lib.rs13
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs1
-rw-r--r--crates/rust-analyzer/src/global_state.rs1
3 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs
index 7ad941279..ef443fc09 100644
--- a/crates/ra_project_model/src/lib.rs
+++ b/crates/ra_project_model/src/lib.rs
@@ -349,11 +349,7 @@ impl ProjectWorkspace {
349 let file_id = load(&sysroot[krate].root)?; 349 let file_id = load(&sysroot[krate].root)?;
350 350
351 // Crates from sysroot have `cfg(test)` disabled 351 // Crates from sysroot have `cfg(test)` disabled
352 let cfg_options = { 352 let cfg_options = default_cfg_options.clone();
353 let mut opts = default_cfg_options.clone();
354 opts.remove_atom("test");
355 opts
356 };
357 353
358 let env = Env::default(); 354 let env = Env::default();
359 let extern_source = ExternSource::default(); 355 let extern_source = ExternSource::default();
@@ -404,7 +400,12 @@ impl ProjectWorkspace {
404 if let Some(file_id) = load(root) { 400 if let Some(file_id) = load(root) {
405 let edition = cargo[pkg].edition; 401 let edition = cargo[pkg].edition;
406 let cfg_options = { 402 let cfg_options = {
407 let mut opts = default_cfg_options.clone(); 403 let mut opts = {
404 let mut opts = default_cfg_options.clone();
405 opts.insert_atom("test".into());
406 opts
407 };
408
408 for feature in cargo[pkg].features.iter() { 409 for feature in cargo[pkg].features.iter() {
409 opts.insert_key_value("feature".into(), feature.into()); 410 opts.insert_key_value("feature".into(), feature.into());
410 } 411 }
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index c7e86fe0c..46181b677 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -151,7 +151,6 @@ pub(crate) fn load(
151 // FIXME: cfg options? 151 // FIXME: cfg options?
152 let default_cfg_options = { 152 let default_cfg_options = {
153 let mut opts = get_rustc_cfg_options(None); 153 let mut opts = get_rustc_cfg_options(None);
154 opts.insert_atom("test".into());
155 opts.insert_atom("debug_assertion".into()); 154 opts.insert_atom("debug_assertion".into());
156 opts 155 opts
157 }; 156 };
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index 0bebb5bf6..4d871aa34 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -138,7 +138,6 @@ impl GlobalState {
138 // FIXME: Read default cfgs from config 138 // FIXME: Read default cfgs from config
139 let default_cfg_options = { 139 let default_cfg_options = {
140 let mut opts = get_rustc_cfg_options(config.cargo.target.as_ref()); 140 let mut opts = get_rustc_cfg_options(config.cargo.target.as_ref());
141 opts.insert_atom("test".into());
142 opts.insert_atom("debug_assertion".into()); 141 opts.insert_atom("debug_assertion".into());
143 opts 142 opts
144 }; 143 };