aboutsummaryrefslogtreecommitdiff
path: root/crates/project_model/src/cargo_workspace.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/project_model/src/cargo_workspace.rs')
-rw-r--r--crates/project_model/src/cargo_workspace.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs
index d5f6a4025..540b57ae4 100644
--- a/crates/project_model/src/cargo_workspace.rs
+++ b/crates/project_model/src/cargo_workspace.rs
@@ -64,6 +64,13 @@ pub struct CargoConfig {
64 64
65 /// rustc target 65 /// rustc target
66 pub target: Option<String>, 66 pub target: Option<String>,
67
68 /// Don't load sysroot crates (`std`, `core` & friends). Might be useful
69 /// when debugging isolated issues.
70 pub no_sysroot: bool,
71
72 /// rustc private crate source
73 pub rustc_source: Option<AbsPathBuf>,
67} 74}
68 75
69pub type Package = Idx<PackageData>; 76pub type Package = Idx<PackageData>;
@@ -137,27 +144,27 @@ impl PackageData {
137impl CargoWorkspace { 144impl CargoWorkspace {
138 pub fn from_cargo_metadata( 145 pub fn from_cargo_metadata(
139 cargo_toml: &AbsPath, 146 cargo_toml: &AbsPath,
140 cargo_features: &CargoConfig, 147 config: &CargoConfig,
141 ) -> Result<CargoWorkspace> { 148 ) -> Result<CargoWorkspace> {
142 let mut meta = MetadataCommand::new(); 149 let mut meta = MetadataCommand::new();
143 meta.cargo_path(toolchain::cargo()); 150 meta.cargo_path(toolchain::cargo());
144 meta.manifest_path(cargo_toml.to_path_buf()); 151 meta.manifest_path(cargo_toml.to_path_buf());
145 if cargo_features.all_features { 152 if config.all_features {
146 meta.features(CargoOpt::AllFeatures); 153 meta.features(CargoOpt::AllFeatures);
147 } else { 154 } else {
148 if cargo_features.no_default_features { 155 if config.no_default_features {
149 // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` 156 // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures`
150 // https://github.com/oli-obk/cargo_metadata/issues/79 157 // https://github.com/oli-obk/cargo_metadata/issues/79
151 meta.features(CargoOpt::NoDefaultFeatures); 158 meta.features(CargoOpt::NoDefaultFeatures);
152 } 159 }
153 if !cargo_features.features.is_empty() { 160 if !config.features.is_empty() {
154 meta.features(CargoOpt::SomeFeatures(cargo_features.features.clone())); 161 meta.features(CargoOpt::SomeFeatures(config.features.clone()));
155 } 162 }
156 } 163 }
157 if let Some(parent) = cargo_toml.parent() { 164 if let Some(parent) = cargo_toml.parent() {
158 meta.current_dir(parent.to_path_buf()); 165 meta.current_dir(parent.to_path_buf());
159 } 166 }
160 if let Some(target) = cargo_features.target.as_ref() { 167 if let Some(target) = config.target.as_ref() {
161 meta.other_options(vec![String::from("--filter-platform"), target.clone()]); 168 meta.other_options(vec![String::from("--filter-platform"), target.clone()]);
162 } 169 }
163 let mut meta = meta.exec().with_context(|| { 170 let mut meta = meta.exec().with_context(|| {
@@ -167,8 +174,8 @@ impl CargoWorkspace {
167 let mut out_dir_by_id = FxHashMap::default(); 174 let mut out_dir_by_id = FxHashMap::default();
168 let mut cfgs = FxHashMap::default(); 175 let mut cfgs = FxHashMap::default();
169 let mut proc_macro_dylib_paths = FxHashMap::default(); 176 let mut proc_macro_dylib_paths = FxHashMap::default();
170 if cargo_features.load_out_dirs_from_check { 177 if config.load_out_dirs_from_check {
171 let resources = load_extern_resources(cargo_toml, cargo_features)?; 178 let resources = load_extern_resources(cargo_toml, config)?;
172 out_dir_by_id = resources.out_dirs; 179 out_dir_by_id = resources.out_dirs;
173 cfgs = resources.cfgs; 180 cfgs = resources.cfgs;
174 proc_macro_dylib_paths = resources.proc_dylib_paths; 181 proc_macro_dylib_paths = resources.proc_dylib_paths;