Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit df824c5

Browse files
committed
Update cargo_metadata -> 0.7
1 parent b3a6ebb commit df824c5

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/build/cargo_plan.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,10 @@ use cargo::core::{PackageId, Target, TargetKind};
3535
use cargo::util::ProcessBuilder;
3636
use cargo_metadata;
3737
use log::{error, trace};
38-
use url::Url;
3938

40-
use crate::build::PackageArg;
41-
use crate::build::plan::{BuildKey, BuildGraph, JobQueue, WorkStatus};
39+
use crate::build::plan::{BuildGraph, BuildKey, JobQueue, WorkStatus};
4240
use crate::build::rustc::src_path;
43-
use crate::lsp_data::parse_file_path;
41+
use crate::build::PackageArg;
4442

4543
/// Main key type by which `Unit`s will be distinguished in the build plan.
4644
/// In Target we're mostly interested in TargetKind (Lib, Bin, ...) and name
@@ -455,19 +453,16 @@ impl PackageMap {
455453
// Find each package in the workspace and record the root directory and package name.
456454
fn discover_package_paths(manifest_path: &Path) -> HashMap<PathBuf, String> {
457455
trace!("read metadata {:?}", manifest_path);
458-
let metadata = match cargo_metadata::metadata(Some(manifest_path)) {
459-
Ok(metadata) => metadata,
460-
Err(_) => return HashMap::new(),
461-
};
462-
metadata
463-
.workspace_members
464-
.into_iter()
465-
.map(|wm| {
466-
assert!(wm.url().starts_with("path+"));
467-
let url = Url::parse(&wm.url()[5..]).expect("Bad URL");
468-
let path = parse_file_path(&url).expect("URL not a path");
469-
(path, wm.name().into())
470-
}).collect()
456+
cargo_metadata::MetadataCommand::new()
457+
.manifest_path(manifest_path)
458+
.exec()
459+
.iter()
460+
.flat_map(|meta| meta.workspace_members.iter().map(move |id| &meta[id]))
461+
.filter_map(|pkg| {
462+
let dir = pkg.manifest_path.parent()?.to_path_buf();
463+
Some((dir, pkg.name.clone()))
464+
})
465+
.collect()
471466
}
472467

473468
/// Given modified set of files, returns a set of corresponding dirty packages.

0 commit comments

Comments
 (0)