mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
refactor: struct holding cargo cfgs settings
This commit is contained in:
parent
1e975d6ee4
commit
1c5a125beb
@ -571,12 +571,10 @@ config_data! {
|
|||||||
/// avoid checking unnecessary things.
|
/// avoid checking unnecessary things.
|
||||||
cargo_buildScripts_useRustcWrapper: bool = true,
|
cargo_buildScripts_useRustcWrapper: bool = true,
|
||||||
/// List of cfg options to enable with the given values.
|
/// List of cfg options to enable with the given values.
|
||||||
cargo_cfgs: FxHashMap<String, Option<String>> = {
|
cargo_cfgs: Vec<String> = {
|
||||||
let mut m = FxHashMap::default();
|
vec!["debug_assertion".into(), "miri".into()]
|
||||||
m.insert("debug_assertions".to_owned(), None);
|
}
|
||||||
m.insert("miri".to_owned(), None);
|
,
|
||||||
m
|
|
||||||
},
|
|
||||||
/// Extra arguments that are passed to every cargo invocation.
|
/// Extra arguments that are passed to every cargo invocation.
|
||||||
cargo_extraArgs: Vec<String> = vec![],
|
cargo_extraArgs: Vec<String> = vec![],
|
||||||
/// Extra environment variables that will be set when running cargo, rustc
|
/// Extra environment variables that will be set when running cargo, rustc
|
||||||
@ -1944,6 +1942,17 @@ impl Config {
|
|||||||
global: CfgDiff::new(
|
global: CfgDiff::new(
|
||||||
self.cargo_cfgs(source_root)
|
self.cargo_cfgs(source_root)
|
||||||
.iter()
|
.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 {
|
.map(|(key, val)| match val {
|
||||||
Some(val) => CfgAtom::KeyValue {
|
Some(val) => CfgAtom::KeyValue {
|
||||||
key: Symbol::intern(key),
|
key: Symbol::intern(key),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user