Update cargo-metadata

This commit is contained in:
Edwin Cheng 2020-05-10 06:22:26 +08:00
parent 8295a9340c
commit 2400d70442
9 changed files with 28 additions and 41 deletions

12
Cargo.lock generated
View file

@ -89,9 +89,9 @@ dependencies = [
[[package]] [[package]]
name = "cargo_metadata" name = "cargo_metadata"
version = "0.9.1" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46e3374c604fb39d1a2f35ed5e4a4e30e60d01fab49446e08f1b3e9a90aef202" checksum = "b8de60b887edf6d74370fc8eb177040da4847d971d6234c7b13a6da324ef0caf"
dependencies = [ dependencies = [
"semver", "semver",
"serde", "serde",
@ -1515,18 +1515,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.106" version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36df6ac6412072f67cf767ebbde4133a5b2e88e76dc6187fa7104cd16f783399" checksum = "eba7550f2cdf88ffc23ab0f1607133486c390a8c0f89b57e589b9654ee15e04d"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.106" version = "1.0.107"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e549e3abf4fb8621bd1609f11dfc9f5e50320802273b12f3811a67e6716ea6c" checksum = "10be45e22e5597d4b88afcc71f9d7bfadcd604bf0c78a3ab4582b8d2b37f39f3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -11,7 +11,7 @@ doctest = false
crossbeam-channel = "0.4.0" crossbeam-channel = "0.4.0"
lsp-types = { version = "0.74.0", features = ["proposed"] } lsp-types = { version = "0.74.0", features = ["proposed"] }
log = "0.4.8" log = "0.4.8"
cargo_metadata = "0.9.1" cargo_metadata = "0.10.0"
serde_json = "1.0.48" serde_json = "1.0.48"
jod-thread = "0.1.1" jod-thread = "0.1.1"
ra_env = { path = "../ra_env" } ra_env = { path = "../ra_env" }

View file

@ -205,6 +205,8 @@ impl FlycheckThread {
} }
CheckEvent::Msg(Message::BuildScriptExecuted(_msg)) => {} CheckEvent::Msg(Message::BuildScriptExecuted(_msg)) => {}
CheckEvent::Msg(Message::BuildFinished(_)) => {}
CheckEvent::Msg(Message::TextLine(_)) => {}
CheckEvent::Msg(Message::Unknown) => {} CheckEvent::Msg(Message::Unknown) => {}
} }
} }

View file

@ -18,7 +18,7 @@ memmap = "0.7"
test_utils = { path = "../test_utils" } test_utils = { path = "../test_utils" }
[dev-dependencies] [dev-dependencies]
cargo_metadata = "0.9.1" cargo_metadata = "0.10.0"
difference = "2.0.0" difference = "2.0.0"
# used as proc macro test target # used as proc macro test target
serde_derive = "=1.0.106" serde_derive = "1.0.106"

View file

@ -20,26 +20,15 @@ SUBTREE $
PUNCH = [alone] 4294967295 PUNCH = [alone] 4294967295
SUBTREE {} 4294967295 SUBTREE {} 4294967295
PUNCH # [alone] 4294967295 PUNCH # [alone] 4294967295
SUBTREE [] 4294967295
IDENT allow 4294967295
SUBTREE () 4294967295
IDENT unknown_lints 4294967295
PUNCH # [alone] 4294967295
SUBTREE [] 4294967295
IDENT cfg_attr 4294967295
SUBTREE () 4294967295
IDENT feature 4294967295
PUNCH = [alone] 4294967295
LITERAL "cargo-clippy" 0
PUNCH , [alone] 4294967295
IDENT allow 4294967295
SUBTREE () 4294967295
IDENT useless_attribute 4294967295
PUNCH # [alone] 4294967295
SUBTREE [] 4294967295 SUBTREE [] 4294967295
IDENT allow 4294967295 IDENT allow 4294967295
SUBTREE () 4294967295 SUBTREE () 4294967295
IDENT rust_2018_idioms 4294967295 IDENT rust_2018_idioms 4294967295
PUNCH , [alone] 4294967295
IDENT clippy 4294967295
PUNCH : [joint] 4294967295
PUNCH : [alone] 4294967295
IDENT useless_attribute 4294967295
IDENT extern 4294967295 IDENT extern 4294967295
IDENT crate 4294967295 IDENT crate 4294967295
IDENT serde 4294967295 IDENT serde 4294967295

View file

@ -10,7 +10,7 @@ fn test_derive_serialize_proc_macro() {
assert_expand( assert_expand(
"serde_derive", "serde_derive",
"Serialize", "Serialize",
"1.0.106", "1.0",
r##"struct Foo {}"##, r##"struct Foo {}"##,
include_str!("fixtures/test_serialize_proc_macro.txt"), include_str!("fixtures/test_serialize_proc_macro.txt"),
); );
@ -21,7 +21,7 @@ fn test_derive_serialize_proc_macro_failed() {
assert_expand( assert_expand(
"serde_derive", "serde_derive",
"Serialize", "Serialize",
"1.0.106", "1.0",
r##" r##"
struct {} struct {}
"##, "##,
@ -37,7 +37,7 @@ SUBTREE $
#[test] #[test]
fn test_derive_proc_macro_list() { fn test_derive_proc_macro_list() {
let res = list("serde_derive", "1.0.106").join("\n"); let res = list("serde_derive", "1.0").join("\n");
assert_eq_text!( assert_eq_text!(
&res, &res,

View file

@ -8,7 +8,7 @@ use std::str::FromStr;
use test_utils::assert_eq_text; use test_utils::assert_eq_text;
mod fixtures { mod fixtures {
use cargo_metadata::{parse_messages, Message}; use cargo_metadata::Message;
use std::process::Command; use std::process::Command;
// Use current project metadata to get the proc-macro dylib path // Use current project metadata to get the proc-macro dylib path
@ -19,12 +19,12 @@ mod fixtures {
.unwrap() .unwrap()
.stdout; .stdout;
for message in parse_messages(command.as_slice()) { for message in Message::parse_stream(command.as_slice()) {
match message.unwrap() { match message.unwrap() {
Message::CompilerArtifact(artifact) => { Message::CompilerArtifact(artifact) => {
if artifact.target.kind.contains(&"proc-macro".to_string()) { if artifact.target.kind.contains(&"proc-macro".to_string()) {
let repr = format!("{} {}", crate_name, version); let repr = format!("{} {}", crate_name, version);
if artifact.package_id.repr.starts_with(&repr) { if artifact.package_id.repr.starts_with(dbg!(&repr)) {
return artifact.filenames[0].clone(); return artifact.filenames[0].clone();
} }
} }

View file

@ -11,7 +11,7 @@ doctest = false
log = "0.4.8" log = "0.4.8"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
cargo_metadata = "0.9.1" cargo_metadata = "0.10.0"
ra_arena = { path = "../ra_arena" } ra_arena = { path = "../ra_arena" }
ra_cfg = { path = "../ra_cfg" } ra_cfg = { path = "../ra_cfg" }

View file

@ -162,7 +162,7 @@ impl CargoWorkspace {
meta.current_dir(parent); meta.current_dir(parent);
} }
if let Some(target) = cargo_features.target.as_ref() { if let Some(target) = cargo_features.target.as_ref() {
meta.other_options(&[String::from("--filter-platform"), target.clone()]); meta.other_options(vec![String::from("--filter-platform"), target.clone()]);
} }
let meta = meta.exec().with_context(|| { let meta = meta.exec().with_context(|| {
format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display()) format!("Failed to run `cargo metadata --manifest-path {}`", cargo_toml.display())
@ -305,19 +305,13 @@ pub fn load_extern_resources(
let mut res = ExternResources::default(); let mut res = ExternResources::default();
for message in cargo_metadata::parse_messages(output.stdout.as_slice()) { for message in cargo_metadata::Message::parse_stream(output.stdout.as_slice()) {
if let Ok(message) = message { if let Ok(message) = message {
match message { match message {
Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => { Message::BuildScriptExecuted(BuildScript { package_id, out_dir, cfgs, .. }) => {
res.out_dirs.insert(package_id.clone(), out_dir); res.out_dirs.insert(package_id.clone(), out_dir);
res.cfgs.insert( res.cfgs.insert(package_id, cfgs);
package_id,
// FIXME: Current `cargo_metadata` uses `PathBuf` instead of `String`,
// change when https://github.com/oli-obk/cargo_metadata/pulls/112 reaches crates.io
cfgs.iter().filter_map(|c| c.to_str().map(|s| s.to_owned())).collect(),
);
} }
Message::CompilerArtifact(message) => { Message::CompilerArtifact(message) => {
if message.target.kind.contains(&"proc-macro".to_string()) { if message.target.kind.contains(&"proc-macro".to_string()) {
let package_id = message.package_id; let package_id = message.package_id;
@ -330,6 +324,8 @@ pub fn load_extern_resources(
} }
Message::CompilerMessage(_) => (), Message::CompilerMessage(_) => (),
Message::Unknown => (), Message::Unknown => (),
Message::BuildFinished(_) => {}
Message::TextLine(_) => {}
} }
} }
} }