diff options
Diffstat (limited to 'crates/ra_project_model')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 27 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 6 |
2 files changed, 16 insertions, 17 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index c2857dbfc..c7f9bd873 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -6,7 +6,7 @@ use std::{ | |||
6 | }; | 6 | }; |
7 | 7 | ||
8 | use anyhow::{Context, Result}; | 8 | use anyhow::{Context, Result}; |
9 | use cargo_metadata::{CargoOpt, Message, MetadataCommand, PackageId}; | 9 | use cargo_metadata::{BuildScript, CargoOpt, Message, MetadataCommand, PackageId}; |
10 | use ra_arena::{Arena, Idx}; | 10 | use ra_arena::{Arena, Idx}; |
11 | use ra_cargo_watch::run_cargo; | 11 | use ra_cargo_watch::run_cargo; |
12 | use ra_db::Edition; | 12 | use ra_db::Edition; |
@@ -254,7 +254,7 @@ pub fn load_out_dirs( | |||
254 | "check".to_string(), | 254 | "check".to_string(), |
255 | "--message-format=json".to_string(), | 255 | "--message-format=json".to_string(), |
256 | "--manifest-path".to_string(), | 256 | "--manifest-path".to_string(), |
257 | format!("{}", cargo_toml.display()), | 257 | cargo_toml.display().to_string(), |
258 | ]; | 258 | ]; |
259 | 259 | ||
260 | if cargo_features.all_features { | 260 | if cargo_features.all_features { |
@@ -263,19 +263,15 @@ pub fn load_out_dirs( | |||
263 | // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` | 263 | // FIXME: `NoDefaultFeatures` is mutual exclusive with `SomeFeatures` |
264 | // https://github.com/oli-obk/cargo_metadata/issues/79 | 264 | // https://github.com/oli-obk/cargo_metadata/issues/79 |
265 | args.push("--no-default-features".to_string()); | 265 | args.push("--no-default-features".to_string()); |
266 | } else if !cargo_features.features.is_empty() { | 266 | } else { |
267 | for feature in &cargo_features.features { | 267 | args.extend(cargo_features.features.iter().cloned()); |
268 | args.push(feature.clone()); | ||
269 | } | ||
270 | } | 268 | } |
271 | 269 | ||
272 | let mut res = FxHashMap::default(); | 270 | let mut acc = FxHashMap::default(); |
273 | let mut child = run_cargo(&args, cargo_toml.parent(), &mut |message| { | 271 | let res = run_cargo(&args, cargo_toml.parent(), &mut |message| { |
274 | match message { | 272 | match message { |
275 | Message::BuildScriptExecuted(message) => { | 273 | Message::BuildScriptExecuted(BuildScript { package_id, out_dir, .. }) => { |
276 | let package_id = message.package_id; | 274 | acc.insert(package_id, out_dir); |
277 | let out_dir = message.out_dir; | ||
278 | res.insert(package_id, out_dir); | ||
279 | } | 275 | } |
280 | 276 | ||
281 | Message::CompilerArtifact(_) => (), | 277 | Message::CompilerArtifact(_) => (), |
@@ -285,6 +281,9 @@ pub fn load_out_dirs( | |||
285 | true | 281 | true |
286 | }); | 282 | }); |
287 | 283 | ||
288 | let _ = child.wait(); | 284 | if let Err(err) = res { |
289 | res | 285 | log::error!("Failed to load outdirs: {:?}", err); |
286 | } | ||
287 | |||
288 | acc | ||
290 | } | 289 | } |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index b500a74fb..a3ef9acdc 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -336,7 +336,7 @@ impl ProjectWorkspace { | |||
336 | extern_source, | 336 | extern_source, |
337 | ); | 337 | ); |
338 | if cargo[tgt].kind == TargetKind::Lib { | 338 | if cargo[tgt].kind == TargetKind::Lib { |
339 | lib_tgt = Some(crate_id); | 339 | lib_tgt = Some((crate_id, cargo[tgt].name.clone())); |
340 | pkg_to_lib_crate.insert(pkg, crate_id); | 340 | pkg_to_lib_crate.insert(pkg, crate_id); |
341 | } | 341 | } |
342 | if cargo[tgt].is_proc_macro { | 342 | if cargo[tgt].is_proc_macro { |
@@ -363,7 +363,7 @@ impl ProjectWorkspace { | |||
363 | 363 | ||
364 | // Set deps to the core, std and to the lib target of the current package | 364 | // Set deps to the core, std and to the lib target of the current package |
365 | for &from in pkg_crates.get(&pkg).into_iter().flatten() { | 365 | for &from in pkg_crates.get(&pkg).into_iter().flatten() { |
366 | if let Some(to) = lib_tgt { | 366 | if let Some((to, name)) = lib_tgt.clone() { |
367 | if to != from | 367 | if to != from |
368 | && crate_graph | 368 | && crate_graph |
369 | .add_dep( | 369 | .add_dep( |
@@ -371,7 +371,7 @@ impl ProjectWorkspace { | |||
371 | // For root projects with dashes in their name, | 371 | // For root projects with dashes in their name, |
372 | // cargo metadata does not do any normalization, | 372 | // cargo metadata does not do any normalization, |
373 | // so we do it ourselves currently | 373 | // so we do it ourselves currently |
374 | CrateName::normalize_dashes(&cargo[pkg].name), | 374 | CrateName::normalize_dashes(&name), |
375 | to, | 375 | to, |
376 | ) | 376 | ) |
377 | .is_err() | 377 | .is_err() |