diff options
| author | bors <bors@rust-lang.org> | 2024-04-19 16:00:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-19 16:00:54 +0000 |
| commit | 50bdeaad07f1f052d1c6fc4d504a8b5f01596ec0 (patch) | |
| tree | 876e094e8da39bb5db0a68e89b9c79a26ff198a1 /crates/rust-analyzer | |
| parent | 05428c56404a7751f3bd6cb61d739a8249f01ebc (diff) | |
| parent | cdb8c3a3279d0ac6fcc4571fdd79bbe91849f4c9 (diff) | |
| download | rust-50bdeaad07f1f052d1c6fc4d504a8b5f01596ec0.tar.gz rust-50bdeaad07f1f052d1c6fc4d504a8b5f01596ec0.zip | |
Auto merge of #17108 - Veykril:rustc-ws-hacks, r=Veykril
internal: Cleanup cfg and env handling in project-model Fixes https://github.com/rust-lang/rust-analyzer/issues/16122#issuecomment-2065794340 `miri` and `debug_assertions` are now enabled via the `cargo.cfgs` config by default, allowing them to be disabled by overwriting the config.
Diffstat (limited to 'crates/rust-analyzer')
| -rw-r--r-- | crates/rust-analyzer/src/cli/rustc_tests.rs | 1 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/config.rs | 19 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/reload.rs | 1 |
3 files changed, 14 insertions, 7 deletions
diff --git a/crates/rust-analyzer/src/cli/rustc_tests.rs b/crates/rust-analyzer/src/cli/rustc_tests.rs index eeec13a14be..548dd4e70e5 100644 --- a/crates/rust-analyzer/src/cli/rustc_tests.rs +++ b/crates/rust-analyzer/src/cli/rustc_tests.rs @@ -81,6 +81,7 @@ impl Tester { rustc_cfg: vec![], toolchain: None, target_layout: data_layout.map(Arc::from).map_err(|it| Arc::from(it.to_string())), + cfg_overrides: Default::default(), }; let load_cargo_config = LoadCargoConfig { load_out_dirs_from_check: false, diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 5dfd7c44357..e956791d9df 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -124,7 +124,12 @@ config_data! { /// avoid checking unnecessary things. cargo_buildScripts_useRustcWrapper: bool = true, /// List of cfg options to enable with the given values. - cargo_cfgs: FxHashMap<String, String> = FxHashMap::default(), + cargo_cfgs: FxHashMap<String, Option<String>> = { + let mut m = FxHashMap::default(); + m.insert("debug_assertions".to_owned(), None); + m.insert("miri".to_owned(), None); + m + }, /// Extra arguments that are passed to every cargo invocation. cargo_extraArgs: Vec<String> = vec![], /// Extra environment variables that will be set when running cargo, rustc @@ -1601,12 +1606,9 @@ impl Config { global: CfgDiff::new( self.cargo_cfgs() .iter() - .map(|(key, val)| { - if val.is_empty() { - CfgAtom::Flag(key.into()) - } else { - CfgAtom::KeyValue { key: key.into(), value: val.into() } - } + .map(|(key, val)| match val { + Some(val) => CfgAtom::KeyValue { key: key.into(), value: val.into() }, + None => CfgAtom::Flag(key.into()), }) .collect(), vec![], @@ -2678,6 +2680,9 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json "FxHashMap<Box<str>, usize>" => set! { "type": "object", }, + "FxHashMap<String, Option<String>>" => set! { + "type": "object", + }, "Option<usize>" => set! { "type": ["null", "integer"], "minimum": 0, diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index d2e495dbfcd..00a61758f06 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -234,6 +234,7 @@ impl GlobalState { it.clone(), cargo_config.target.as_deref(), &cargo_config.extra_env, + &cargo_config.cfg_overrides, )) } }) |
