diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2025-01-09 10:19:55 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-09 10:19:55 +0000 |
| commit | f4ecc34aa71109596fe7d8a809614a5d25732213 (patch) | |
| tree | c2ff7c6aef45f0006fc2bcb2ed8c41197b734829 | |
| parent | 85310c4f25cd717ac8ae5469a96a88acf5d83d98 (diff) | |
| parent | 93d08b7c7741d4a7233c344caa760d74f8a9c583 (diff) | |
| download | rust-f4ecc34aa71109596fe7d8a809614a5d25732213.tar.gz rust-f4ecc34aa71109596fe7d8a809614a5d25732213.zip | |
Merge pull request #18885 from qjerome/refactor-cargo-cfgs
refactor: struct holding cargo cfgs settings
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs | 14 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/docs/user/generated_config.adoc | 8 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/editors/code/package.json | 13 |
3 files changed, 21 insertions, 14 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs index 30f0031905f..051871020af 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -571,11 +571,8 @@ 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, Option<String>> = { - let mut m = FxHashMap::default(); - m.insert("debug_assertions".to_owned(), None); - m.insert("miri".to_owned(), None); - m + cargo_cfgs: Vec<String> = { + vec!["debug_assertion".into(), "miri".into()] }, /// Extra arguments that are passed to every cargo invocation. cargo_extraArgs: Vec<String> = vec![], @@ -1944,6 +1941,13 @@ impl Config { global: CfgDiff::new( self.cargo_cfgs(source_root) .iter() + // parse any cfg setting formatted as key=value or just key (without value) + .filter_map(|s| { + let mut sp = s.splitn(2, "="); + let key = sp.next(); + let val = sp.next(); + key.map(|key| (key, val)) + }) .map(|(key, val)| match val { Some(val) => CfgAtom::KeyValue { key: Symbol::intern(key), diff --git a/src/tools/rust-analyzer/docs/user/generated_config.adoc b/src/tools/rust-analyzer/docs/user/generated_config.adoc index 5b86766aa8e..c6f5852f87f 100644 --- a/src/tools/rust-analyzer/docs/user/generated_config.adoc +++ b/src/tools/rust-analyzer/docs/user/generated_config.adoc @@ -94,10 +94,10 @@ avoid checking unnecessary things. -- Default: ---- -{ - "miri": null, - "debug_assertions": null -} +[ + "debug_assertion", + "miri" +] ---- List of cfg options to enable with the given values. diff --git a/src/tools/rust-analyzer/editors/code/package.json b/src/tools/rust-analyzer/editors/code/package.json index 80246bf3fea..6cb74a94a00 100644 --- a/src/tools/rust-analyzer/editors/code/package.json +++ b/src/tools/rust-analyzer/editors/code/package.json @@ -791,11 +791,14 @@ "properties": { "rust-analyzer.cargo.cfgs": { "markdownDescription": "List of cfg options to enable with the given values.", - "default": { - "miri": null, - "debug_assertions": null - }, - "type": "object" + "default": [ + "debug_assertion", + "miri" + ], + "type": "array", + "items": { + "type": "string" + } } } }, |
