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