Discover rustc_cfg through unstable cargo options

This commit is contained in:
Lukas Wirth 2021-05-08 18:17:18 +02:00
parent 526040eea8
commit 8989fb8315
3 changed files with 83 additions and 33 deletions

View file

@ -143,7 +143,8 @@ impl ProjectWorkspace {
} else {
None
};
let rustc_cfg = rustc_cfg::get(config.target.as_deref());
let rustc_cfg = rustc_cfg::get(Some(&cargo_toml), config.target.as_deref());
ProjectWorkspace::Cargo { cargo, sysroot, rustc, rustc_cfg }
}
};
@ -159,7 +160,7 @@ impl ProjectWorkspace {
Some(path) => Some(Sysroot::load(path)?),
None => None,
};
let rustc_cfg = rustc_cfg::get(target);
let rustc_cfg = rustc_cfg::get(None, target);
Ok(ProjectWorkspace::Json { project: project_json, sysroot, rustc_cfg })
}
@ -310,7 +311,7 @@ fn project_json_to_crate_graph(
let target_cfgs = match krate.target.as_deref() {
Some(target) => {
cfg_cache.entry(target).or_insert_with(|| rustc_cfg::get(Some(target)))
cfg_cache.entry(target).or_insert_with(|| rustc_cfg::get(None, Some(target)))
}
None => &rustc_cfg,
};