diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2023-09-08 11:02:56 +0200 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2023-09-08 11:02:56 +0200 |
| commit | fddef42e92f69b04c2b39d2accbe74a86ae4cc22 (patch) | |
| tree | a853ab517e9ee8b3242b9133d2748f94a699af10 | |
| parent | e9e2c1ae75e7296435c9835a1078c3e14187832a (diff) | |
| download | rust-fddef42e92f69b04c2b39d2accbe74a86ae4cc22.tar.gz rust-fddef42e92f69b04c2b39d2accbe74a86ae4cc22.zip | |
Only set rust-analyzer cfg for workspace members
5 files changed, 5 insertions, 18 deletions
diff --git a/crates/project-model/src/workspace.rs b/crates/project-model/src/workspace.rs index 6e7836f9130..0904ef080d4 100644 --- a/crates/project-model/src/workspace.rs +++ b/crates/project-model/src/workspace.rs @@ -867,6 +867,9 @@ fn cargo_to_crate_graph( if cargo[pkg].is_local { cfg_options.insert_atom("test".into()); } + if cargo[pkg].is_member { + cfg_options.insert_atom("rust_analyzer".into()); + } if !override_cfg.global.is_empty() { cfg_options.apply_diff(override_cfg.global.clone()); @@ -1030,7 +1033,8 @@ fn detached_files_to_crate_graph( None => (SysrootPublicDeps::default(), None), }; - let cfg_options = create_cfg_options(rustc_cfg); + let mut cfg_options = create_cfg_options(rustc_cfg); + cfg_options.insert_atom("rust_analyzer".into()); for detached_file in detached_files { let file_id = match load(detached_file) { @@ -1479,6 +1483,5 @@ fn create_cfg_options(rustc_cfg: Vec<CfgFlag>) -> CfgOptions { let mut cfg_options = CfgOptions::default(); cfg_options.extend(rustc_cfg); cfg_options.insert_atom("debug_assertions".into()); - cfg_options.insert_atom("rust_analyzer".into()); cfg_options } diff --git a/crates/project-model/test_data/output/cargo_hello_world_project_model.txt b/crates/project-model/test_data/output/cargo_hello_world_project_model.txt index b5e49371155..727d39a3077 100644 --- a/crates/project-model/test_data/output/cargo_hello_world_project_model.txt +++ b/crates/project-model/test_data/output/cargo_hello_world_project_model.txt @@ -297,7 +297,6 @@ "debug_assertions", "feature=default", "feature=std", - "rust_analyzer", ], ), potential_cfg_options: Some( @@ -311,7 +310,6 @@ "feature=rustc-dep-of-std", "feature=std", "feature=use_std", - "rust_analyzer", ], ), ), diff --git a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt index b5e49371155..727d39a3077 100644 --- a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt +++ b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_selective_overrides.txt @@ -297,7 +297,6 @@ "debug_assertions", "feature=default", "feature=std", - "rust_analyzer", ], ), potential_cfg_options: Some( @@ -311,7 +310,6 @@ "feature=rustc-dep-of-std", "feature=std", "feature=use_std", - "rust_analyzer", ], ), ), diff --git a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt index 050791d64c3..89728babd82 100644 --- a/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt +++ b/crates/project-model/test_data/output/cargo_hello_world_project_model_with_wildcard_overrides.txt @@ -293,7 +293,6 @@ "debug_assertions", "feature=default", "feature=std", - "rust_analyzer", ], ), potential_cfg_options: Some( @@ -307,7 +306,6 @@ "feature=rustc-dep-of-std", "feature=std", "feature=use_std", - "rust_analyzer", ], ), ), diff --git a/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt b/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt index 24803e7d9ac..b7bf6cb2774 100644 --- a/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt +++ b/crates/project-model/test_data/output/rust_project_hello_world_project_model.txt @@ -16,7 +16,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -58,7 +57,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -92,7 +90,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -126,7 +123,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -160,7 +156,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -209,7 +204,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -243,7 +237,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -334,7 +327,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -368,7 +360,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, @@ -402,7 +393,6 @@ cfg_options: CfgOptions( [ "debug_assertions", - "rust_analyzer", ], ), potential_cfg_options: None, |
