diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 7ad9412795..ef443fc09e 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs @@ -349,11 +349,7 @@ impl ProjectWorkspace { let file_id = load(&sysroot[krate].root)?; // Crates from sysroot have `cfg(test)` disabled - let cfg_options = { - let mut opts = default_cfg_options.clone(); - opts.remove_atom("test"); - opts - }; + let cfg_options = default_cfg_options.clone(); let env = Env::default(); let extern_source = ExternSource::default(); @@ -404,7 +400,12 @@ impl ProjectWorkspace { if let Some(file_id) = load(root) { let edition = cargo[pkg].edition; let cfg_options = { - let mut opts = default_cfg_options.clone(); + let mut opts = { + let mut opts = default_cfg_options.clone(); + opts.insert_atom("test".into()); + opts + }; + for feature in cargo[pkg].features.iter() { opts.insert_key_value("feature".into(), feature.into()); } diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index c7e86fe0c4..46181b677b 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( // FIXME: cfg options? let default_cfg_options = { let mut opts = get_rustc_cfg_options(None); - opts.insert_atom("test".into()); opts.insert_atom("debug_assertion".into()); opts }; diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 0bebb5bf61..4d871aa340 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -138,7 +138,6 @@ impl GlobalState { // FIXME: Read default cfgs from config let default_cfg_options = { let mut opts = get_rustc_cfg_options(config.cargo.target.as_ref()); - opts.insert_atom("test".into()); opts.insert_atom("debug_assertion".into()); opts };