diff options
| author | qjerome <qjerome@rawsec.lu> | 2025-01-08 11:20:08 +0100 |
|---|---|---|
| committer | qjerome <qjerome@rawsec.lu> | 2025-01-08 11:20:08 +0100 |
| commit | 2be4ce099d4af070ba71481a048f175b2da9c1c0 (patch) | |
| tree | af1b6c2476c3e5985eff5c2586818492ce6011ac /src | |
| parent | 16721e33dc6f0e139a4057d86ef99531b8329472 (diff) | |
| download | rust-2be4ce099d4af070ba71481a048f175b2da9c1c0.tar.gz rust-2be4ce099d4af070ba71481a048f175b2da9c1c0.zip | |
refactor: struct holding cargo cfgs settings
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs | 21 |
1 files changed, 15 insertions, 6 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..1fe8d0ce420 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs @@ -571,12 +571,10 @@ 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![], /// Extra environment variables that will be set when running cargo, rustc @@ -1944,6 +1942,17 @@ impl Config { global: CfgDiff::new( self.cargo_cfgs(source_root) .iter() + // parse any cfg setting formatted as key=value + .map(|s| { + let mut sp = s.splitn(2, "="); + let key = sp.next(); + let val = sp.next(); + (key, val) + }) + // we filter out anything with a None key + .filter(|(key, _)| key.is_some()) + // unwrap cannot panic here as we are sure key is Some + .map(|(key, val)| (key.unwrap(), val)) .map(|(key, val)| match val { Some(val) => CfgAtom::KeyValue { key: Symbol::intern(key), |
