Gate #[test] expansion under cfg(test).

This will mean users opting to not activate `cfg(test)` will lose IDE experience on them, which is quite unfortunate, but this is unavoidable if we want to avoid false positives on e.g. diagnostics. The real fix is to provide IDE experience even for cfg'ed out code, but this is out of scope for this PR.
This commit is contained in:
Chayim Refael Friedman 2024-09-09 23:54:22 +03:00
parent 4ea09dd9f6
commit 4a06675e9c
17 changed files with 78 additions and 45 deletions

View file

@ -30,7 +30,6 @@ pub struct LoadCargoConfig {
pub load_out_dirs_from_check: bool,
pub with_proc_macro_server: ProcMacroServerChoice,
pub prefill_caches: bool,
pub set_test: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
@ -100,7 +99,6 @@ pub fn load_workspace(
vfs.file_id(&path)
},
extra_env,
load_config.set_test,
);
let proc_macros = {
let proc_macro_server = match &proc_macro_server {
@ -528,12 +526,11 @@ mod tests {
#[test]
fn test_loading_rust_analyzer() {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
let cargo_config = CargoConfig::default();
let cargo_config = CargoConfig { set_test: true, ..CargoConfig::default() };
let load_cargo_config = LoadCargoConfig {
load_out_dirs_from_check: false,
with_proc_macro_server: ProcMacroServerChoice::None,
prefill_caches: false,
set_test: true,
};
let (db, _vfs, _proc_macro) =
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {}).unwrap();