Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: struct holding cargo cfgs settings #18885

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![],
Expand Down Expand Up @@ -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),
Expand Down
8 changes: 4 additions & 4 deletions docs/user/generated_config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
13 changes: 8 additions & 5 deletions editors/code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
},
Expand Down
Loading