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 { if cargo[pkg].is_local {
cfg_options.insert_atom("test".into()); cfg_options.insert_atom("test".into());
} }
if cargo[pkg].is_member {
cfg_options.insert_atom("rust_analyzer".into());
}
if !override_cfg.global.is_empty() { if !override_cfg.global.is_empty() {
cfg_options.apply_diff(override_cfg.global.clone()); cfg_options.apply_diff(override_cfg.global.clone());
@ -1030,7 +1033,8 @@ fn detached_files_to_crate_graph(
None => (SysrootPublicDeps::default(), None), 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 { for detached_file in detached_files {
let file_id = match load(detached_file) { 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(); let mut cfg_options = CfgOptions::default();
cfg_options.extend(rustc_cfg); cfg_options.extend(rustc_cfg);
cfg_options.insert_atom("debug_assertions".into()); cfg_options.insert_atom("debug_assertions".into());
cfg_options.insert_atom("rust_analyzer".into());
cfg_options cfg_options
} }

View file

@ -297,7 +297,6 @@
"debug_assertions", "debug_assertions",
"feature=default", "feature=default",
"feature=std", "feature=std",
"rust_analyzer",
], ],
), ),
potential_cfg_options: Some( potential_cfg_options: Some(
@ -311,7 +310,6 @@
"feature=rustc-dep-of-std", "feature=rustc-dep-of-std",
"feature=std", "feature=std",
"feature=use_std", "feature=use_std",
"rust_analyzer",
], ],
), ),
), ),

View file

@ -297,7 +297,6 @@
"debug_assertions", "debug_assertions",
"feature=default", "feature=default",
"feature=std", "feature=std",
"rust_analyzer",
], ],
), ),
potential_cfg_options: Some( potential_cfg_options: Some(
@ -311,7 +310,6 @@
"feature=rustc-dep-of-std", "feature=rustc-dep-of-std",
"feature=std", "feature=std",
"feature=use_std", "feature=use_std",
"rust_analyzer",
], ],
), ),
), ),

View file

@ -293,7 +293,6 @@
"debug_assertions", "debug_assertions",
"feature=default", "feature=default",
"feature=std", "feature=std",
"rust_analyzer",
], ],
), ),
potential_cfg_options: Some( potential_cfg_options: Some(
@ -307,7 +306,6 @@
"feature=rustc-dep-of-std", "feature=rustc-dep-of-std",
"feature=std", "feature=std",
"feature=use_std", "feature=use_std",
"rust_analyzer",
], ],
), ),
), ),

View file

@ -16,7 +16,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -58,7 +57,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -92,7 +90,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -126,7 +123,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -160,7 +156,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -209,7 +204,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -243,7 +237,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -334,7 +327,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -368,7 +360,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,
@ -402,7 +393,6 @@
cfg_options: CfgOptions( cfg_options: CfgOptions(
[ [
"debug_assertions", "debug_assertions",
"rust_analyzer",
], ],
), ),
potential_cfg_options: None, potential_cfg_options: None,