Skip to content

Commit d1ea9d1

Browse files
bors[bot]matklad
andauthored
Merge #6545
6545: Simplify project model r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents 700e5e5 + b137736 commit d1ea9d1

File tree

8 files changed

+618
-630
lines changed

8 files changed

+618
-630
lines changed

crates/project_model/src/cargo_workspace.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ pub struct CargoConfig {
6565
/// rustc target
6666
pub target: Option<String>,
6767

68+
/// Don't load sysroot crates (`std`, `core` & friends). Might be useful
69+
/// when debugging isolated issues.
70+
pub no_sysroot: bool,
71+
6872
/// rustc private crate source
6973
pub rustc_source: Option<AbsPathBuf>,
7074
}
@@ -140,27 +144,27 @@ impl PackageData {
140144
impl CargoWorkspace {
141145
pub fn from_cargo_metadata(
142146
cargo_toml: &AbsPath,
143-
cargo_features: &CargoConfig,
147+
config: &CargoConfig,
144148
) -> Result<CargoWorkspace> {
145149
let mut meta = MetadataCommand::new();
146150
meta.cargo_path(toolchain::cargo());
147151
meta.manifest_path(cargo_toml.to_path_buf());
148-
if cargo_features.all_features {
152+
if config.all_features {
149153
meta.features(CargoOpt::AllFeatures);
150154
} else {
151-
if cargo_features.no_default_features {
155+
if config.no_default_features {
152156
// FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
153157
// https://github.com/oli-obk/cargo_metadata/issues/79
154158
meta.features(CargoOpt::NoDefaultFeatures);
155159
}
156-
if !cargo_features.features.is_empty() {
157-
meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone()));
160+
if !config.features.is_empty() {
161+
meta.features(CargoOpt::SomeFeatures(config.features.clone()));
158162
}
159163
}
160164
if let Some(parent) = cargo_toml.parent() {
161165
meta.current_dir(parent.to_path_buf());
162166
}
163-
if let Some(target) = cargo_features.target.as_ref() {
167+
if let Some(target) = config.target.as_ref() {
164168
meta.other_options(vec![String::from("--filter-platform"), target.clone()]);
165169
}
166170
let mut meta = meta.exec().with_context(|| {
@@ -170,8 +174,8 @@ impl CargoWorkspace {
170174
let mut out_dir_by_id = FxHashMap::default();
171175
let mut cfgs = FxHashMap::default();
172176
let mut proc_macro_dylib_paths = FxHashMap::default();
173-
if cargo_features.load_out_dirs_from_check {
174-
let resources = load_extern_resources(cargo_toml, cargo_features)?;
177+
if config.load_out_dirs_from_check {
178+
let resources = load_extern_resources(cargo_toml, config)?;
175179
out_dir_by_id = resources.out_dirs;
176180
cfgs = resources.cfgs;
177181
proc_macro_dylib_paths = resources.proc_dylib_paths;

0 commit comments

Comments
 (0)