mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #466
466: switch to newer cargo-metadata r=matklad a=matklad This handles renames closes https://github.com/rust-analyzer/rust-analyzer/issues/464 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
3b166aee3c
3 changed files with 13 additions and 15 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
@ -113,7 +113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
[[package]]
|
||||
name = "cargo_metadata"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
source = "git+https://github.com/matklad/cargo_metadata.git?branch=well-typed#2f125128c38beeef34e0bfc1bc27861a24753dfe"
|
||||
dependencies = [
|
||||
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -724,7 +724,7 @@ dependencies = [
|
|||
name = "ra_lsp_server"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"cargo_metadata 0.6.4 (git+https://github.com/matklad/cargo_metadata.git?branch=well-typed)",
|
||||
"crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1489,7 +1489,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum block-buffer 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a076c298b9ecdb530ed9d967e74a6027d6a7478924520acddcddc24c1c8ab3ab"
|
||||
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
|
||||
"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
|
||||
"checksum cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e5d1b4d380e1bab994591a24c2bdd1b054f64b60bef483a8c598c7c345bc3bbe"
|
||||
"checksum cargo_metadata 0.6.4 (git+https://github.com/matklad/cargo_metadata.git?branch=well-typed)" = "<none>"
|
||||
"checksum cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4a8b715cb4597106ea87c7c84b2f1d452c7492033765df7f32651e66fcf749"
|
||||
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
|
||||
"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
|
||||
|
|
|
@ -6,3 +6,4 @@ incremental = true
|
|||
debug = true
|
||||
|
||||
[patch.'crates-io']
|
||||
cargo_metadata = { git = "https://github.com/matklad/cargo_metadata.git", branch = "well-typed" }
|
||||
|
|
|
@ -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};
|
||||
|
||||
|
@ -109,11 +109,7 @@ 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());
|
||||
|
@ -121,7 +117,7 @@ impl CargoWorkspace {
|
|||
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(),
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue