Skip to content

Commit

Permalink
Merge #466
Browse files Browse the repository at this point in the history
466: switch to newer cargo-metadata r=matklad a=matklad

This handles renames

closes #464

Co-authored-by: Aleksey Kladov <[email protected]>
  • Loading branch information
bors[bot] and matklad committed Jan 8, 2019
2 parents 63e3afe + 141ab16 commit 3b166ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ incremental = true
debug = true

[patch.'crates-io']
cargo_metadata = { git = "https://github.com/matklad/cargo_metadata.git", branch = "well-typed" }
21 changes: 9 additions & 12 deletions crates/ra_lsp_server/src/project_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf};

use cargo_metadata::{metadata_run, CargoOpt};
use ra_syntax::SmolStr;
use rustc_hash::{FxHashMap, FxHashSet};
use rustc_hash::FxHashMap;
use failure::{format_err, bail};
use thread_worker::{WorkerHandle, Worker};

Expand Down Expand Up @@ -109,19 +109,15 @@ impl CargoWorkspace {
let mut packages = Vec::new();
let mut targets = Vec::new();

let ws_members: FxHashSet<String> = meta
.workspace_members
.into_iter()
.map(|it| it.raw)
.collect();
let ws_members = &meta.workspace_members;

for meta_pkg in meta.packages {
let pkg = Package(packages.len());
let is_member = ws_members.contains(&meta_pkg.id);
pkg_by_id.insert(meta_pkg.id.clone(), pkg);
let mut pkg_data = PackageData {
name: meta_pkg.name.into(),
manifest: PathBuf::from(meta_pkg.manifest_path),
manifest: meta_pkg.manifest_path.clone(),
targets: Vec::new(),
is_member,
dependencies: Vec::new(),
Expand All @@ -131,7 +127,7 @@ impl CargoWorkspace {
targets.push(TargetData {
pkg,
name: meta_tgt.name.into(),
root: PathBuf::from(meta_tgt.src_path),
root: meta_tgt.src_path.clone(),
kind: TargetKind::new(meta_tgt.kind.as_slice()),
});
pkg_data.targets.push(tgt);
Expand All @@ -141,10 +137,11 @@ impl CargoWorkspace {
let resolve = meta.resolve.expect("metadata executed with deps");
for node in resolve.nodes {
let source = pkg_by_id[&node.id];
for id in node.dependencies {
let target = pkg_by_id[&id];
let name: SmolStr = packages[target.0].name.replace('-', "_").into();
let dep = PackageDependency { name, pkg: target };
for dep_node in node.deps {
let dep = PackageDependency {
name: dep_node.name.into(),
pkg: pkg_by_id[&dep_node.pkg],
};
packages[source.0].dependencies.push(dep);
}
}
Expand Down

0 comments on commit 3b166ae

Please sign in to comment.