Skip to content

Commit 8eee914

Browse files
bors[bot]lnicola
andauthored
Merge #7848
7848: Bump cargo_metadata r=matklad a=lnicola Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents f5c25f6 + b20708f commit 8eee914

File tree

9 files changed

+47
-37
lines changed

9 files changed

+47
-37
lines changed

Cargo.lock

Lines changed: 18 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/flycheck/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ doctest = false
1212
[dependencies]
1313
crossbeam-channel = "0.5.0"
1414
log = "0.4.8"
15-
cargo_metadata = "0.12.2"
15+
cargo_metadata = "0.13"
1616
serde_json = "1.0.48"
1717
jod-thread = "0.1.1"
1818

1919
toolchain = { path = "../toolchain", version = "0.0.0" }
20-
stdx = { path = "../stdx", version = "0.0.0" }
20+
stdx = { path = "../stdx", version = "0.0.0" }

crates/flycheck/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl FlycheckActor {
194194
cargo_metadata::Message::BuildScriptExecuted(_)
195195
| cargo_metadata::Message::BuildFinished(_)
196196
| cargo_metadata::Message::TextLine(_)
197-
| cargo_metadata::Message::Unknown => {}
197+
| _ => {}
198198
},
199199
}
200200
}
@@ -329,8 +329,7 @@ impl CargoActor {
329329
// Skip certain kinds of messages to only spend time on what's useful
330330
match &message {
331331
cargo_metadata::Message::CompilerArtifact(artifact) if artifact.fresh => (),
332-
cargo_metadata::Message::BuildScriptExecuted(_)
333-
| cargo_metadata::Message::Unknown => (),
332+
cargo_metadata::Message::BuildScriptExecuted(_) => (),
334333
_ => self.sender.send(message).unwrap(),
335334
}
336335
}

crates/proc_macro_srv/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ proc_macro_api = { path = "../proc_macro_api", version = "0.0.0" }
2020
test_utils = { path = "../test_utils", version = "0.0.0" }
2121

2222
[dev-dependencies]
23-
cargo_metadata = "0.12.2"
23+
cargo_metadata = "0.13"
2424

2525
# used as proc macro test targets
2626
serde_derive = "1.0.106"

crates/proc_macro_srv/src/tests/utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use test_utils::assert_eq_text;
88

99
mod fixtures {
1010
use cargo_metadata::Message;
11+
use std::path::PathBuf;
1112
use std::process::Command;
1213

1314
// Use current project metadata to get the proc-macro dylib path
@@ -24,7 +25,7 @@ mod fixtures {
2425
if artifact.target.kind.contains(&"proc-macro".to_string()) {
2526
let repr = format!("{} {}", crate_name, version);
2627
if artifact.package_id.repr.starts_with(&repr) {
27-
return artifact.filenames[0].clone();
28+
return PathBuf::from(&artifact.filenames[0]);
2829
}
2930
}
3031
}

crates/project_model/Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doctest = false
1212
[dependencies]
1313
log = "0.4.8"
1414
rustc-hash = "1.1.0"
15-
cargo_metadata = "0.12.2"
15+
cargo_metadata = "0.13"
1616
serde = { version = "1.0.106", features = ["derive"] }
1717
serde_json = "1.0.48"
1818
anyhow = "1.0.26"
@@ -22,7 +22,7 @@ la-arena = { version = "0.2.0", path = "../../lib/arena" }
2222
cfg = { path = "../cfg", version = "0.0.0" }
2323
base_db = { path = "../base_db", version = "0.0.0" }
2424
toolchain = { path = "../toolchain", version = "0.0.0" }
25-
proc_macro_api = { path = "../proc_macro_api", version = "0.0.0" }
26-
paths = { path = "../paths", version = "0.0.0" }
27-
stdx = { path = "../stdx", version = "0.0.0" }
28-
profile = { path = "../profile", version = "0.0.0" }
25+
proc_macro_api = { path = "../proc_macro_api", version = "0.0.0" }
26+
paths = { path = "../paths", version = "0.0.0" }
27+
stdx = { path = "../stdx", version = "0.0.0" }
28+
profile = { path = "../profile", version = "0.0.0" }

crates/project_model/src/build_data.rs

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//! Handles build script specific information
22
33
use std::{
4-
ffi::OsStr,
54
io::BufReader,
6-
path::{Path, PathBuf},
5+
path::PathBuf,
76
process::{Command, Stdio},
87
sync::Arc,
98
};
109

1110
use anyhow::Result;
11+
use cargo_metadata::camino::Utf8Path;
1212
use cargo_metadata::{BuildScript, Message};
1313
use itertools::Itertools;
1414
use paths::{AbsPath, AbsPathBuf};
@@ -162,8 +162,8 @@ fn collect_from_workspace(
162162
let res = res.entry(package_id.repr.clone()).or_default();
163163
// cargo_metadata crate returns default (empty) path for
164164
// older cargos, which is not absolute, so work around that.
165-
if out_dir != PathBuf::default() {
166-
let out_dir = AbsPathBuf::assert(out_dir);
165+
if !out_dir.as_str().is_empty() {
166+
let out_dir = AbsPathBuf::assert(PathBuf::from(out_dir.into_os_string()));
167167
res.out_dir = Some(out_dir);
168168
res.cfgs = cfgs;
169169
}
@@ -178,7 +178,7 @@ fn collect_from_workspace(
178178
// Skip rmeta file
179179
if let Some(filename) = message.filenames.iter().find(|name| is_dylib(name))
180180
{
181-
let filename = AbsPathBuf::assert(filename.clone());
181+
let filename = AbsPathBuf::assert(PathBuf::from(&filename));
182182
let res = res.entry(package_id.repr.clone()).or_default();
183183
res.proc_macro_dylib_path = Some(filename);
184184
}
@@ -187,9 +187,9 @@ fn collect_from_workspace(
187187
Message::CompilerMessage(message) => {
188188
progress(message.target.name.clone());
189189
}
190-
Message::Unknown => (),
191190
Message::BuildFinished(_) => {}
192191
Message::TextLine(_) => {}
192+
_ => {}
193193
}
194194
}
195195
}
@@ -209,8 +209,8 @@ fn collect_from_workspace(
209209
}
210210

211211
// FIXME: File a better way to know if it is a dylib
212-
fn is_dylib(path: &Path) -> bool {
213-
match path.extension().and_then(OsStr::to_str).map(|it| it.to_string().to_lowercase()) {
212+
fn is_dylib(path: &Utf8Path) -> bool {
213+
match path.extension().map(|e| e.to_string().to_lowercase()) {
214214
None => false,
215215
Some(ext) => matches!(ext.as_str(), "dll" | "dylib" | "so"),
216216
}
@@ -227,9 +227,7 @@ fn inject_cargo_env(package: &cargo_metadata::Package, build_data: &mut BuildDat
227227

228228
let mut manifest_dir = package.manifest_path.clone();
229229
manifest_dir.pop();
230-
if let Some(cargo_manifest_dir) = manifest_dir.to_str() {
231-
env.push(("CARGO_MANIFEST_DIR".into(), cargo_manifest_dir.into()));
232-
}
230+
env.push(("CARGO_MANIFEST_DIR".into(), manifest_dir.into_string()));
233231

234232
// Not always right, but works for common cases.
235233
env.push(("CARGO".into(), "cargo".into()));
@@ -251,7 +249,6 @@ fn inject_cargo_env(package: &cargo_metadata::Package, build_data: &mut BuildDat
251249
env.push(("CARGO_PKG_REPOSITORY".into(), package.repository.clone().unwrap_or_default()));
252250
env.push(("CARGO_PKG_LICENSE".into(), package.license.clone().unwrap_or_default()));
253251

254-
let license_file =
255-
package.license_file.as_ref().map(|buf| buf.display().to_string()).unwrap_or_default();
252+
let license_file = package.license_file.as_ref().map(|buf| buf.to_string()).unwrap_or_default();
256253
env.push(("CARGO_PKG_LICENSE_FILE".into(), license_file));
257254
}

crates/project_model/src/cargo_workspace.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! FIXME: write short doc here
22
3+
use std::path::PathBuf;
34
use std::{convert::TryInto, ops, process::Command, sync::Arc};
45

56
use anyhow::{Context, Result};
@@ -249,11 +250,12 @@ impl CargoWorkspace {
249250
let edition = edition
250251
.parse::<Edition>()
251252
.with_context(|| format!("Failed to parse edition {}", edition))?;
253+
252254
let pkg = packages.alloc(PackageData {
253255
id: id.repr.clone(),
254256
name: name.clone(),
255257
version: version.to_string(),
256-
manifest: AbsPathBuf::assert(manifest_path.clone()),
258+
manifest: AbsPathBuf::assert(PathBuf::from(&manifest_path)),
257259
targets: Vec::new(),
258260
is_member,
259261
edition,
@@ -268,7 +270,7 @@ impl CargoWorkspace {
268270
let tgt = targets.alloc(TargetData {
269271
package: pkg,
270272
name: meta_tgt.name.clone(),
271-
root: AbsPathBuf::assert(meta_tgt.src_path.clone()),
273+
root: AbsPathBuf::assert(PathBuf::from(&meta_tgt.src_path)),
272274
kind: TargetKind::new(meta_tgt.kind.as_slice()),
273275
is_proc_macro,
274276
});
@@ -305,7 +307,8 @@ impl CargoWorkspace {
305307
packages[source].active_features.extend(node.features);
306308
}
307309

308-
let workspace_root = AbsPathBuf::assert(meta.workspace_root);
310+
let workspace_root =
311+
AbsPathBuf::assert(PathBuf::from(meta.workspace_root.into_os_string()));
309312
let build_data_config = BuildDataConfig::new(
310313
cargo_toml.to_path_buf(),
311314
config.clone(),

crates/rust-analyzer/src/diagnostics/to_proto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn diagnostic_severity(
2929
},
3030
DiagnosticLevel::Note => lsp_types::DiagnosticSeverity::Information,
3131
DiagnosticLevel::Help => lsp_types::DiagnosticSeverity::Hint,
32-
DiagnosticLevel::Unknown => return None,
32+
_ => return None,
3333
};
3434
Some(res)
3535
}

0 commit comments

Comments
 (0)