Only set rust-analyzer cfg for workspace members

This commit is contained in:
Lukas Wirth 2023-09-08 11:02:56 +02:00
parent e9e2c1ae75
commit fddef42e92
5 changed files with 5 additions and 18 deletions

View File

@ -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
}

View File

@ -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",
],
),
),

View File

@ -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",
],
),
),

View File

@ -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",
],
),
),

View File

@ -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,