Skip to content

Commit d6b740f

Browse files
committed
refactor: use Cow on artifact notification
`artifact` field is an (absolute) path to emitted artifact like /home/projects/foo/target/debug/deps/libbar-73d672db2af2c9a8.rmeta It is worth not copying them.
1 parent cdba1c7 commit d6b740f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/cargo/core/compiler/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,11 +1852,12 @@ fn on_stderr_line_inner(
18521852
// Look for a matching directive and inform Cargo internally that a
18531853
// metadata file has been produced.
18541854
#[derive(serde::Deserialize)]
1855-
struct ArtifactNotification {
1856-
artifact: String,
1855+
struct ArtifactNotification<'a> {
1856+
#[serde(borrow)]
1857+
artifact: Cow<'a, str>,
18571858
}
18581859

1859-
if let Ok(artifact) = serde_json::from_str::<ArtifactNotification>(compiler_message.get()) {
1860+
if let Ok(artifact) = serde_json::from_str::<ArtifactNotification<'_>>(compiler_message.get()) {
18601861
trace!("found directive from rustc: `{}`", artifact.artifact);
18611862
if artifact.artifact.ends_with(".rmeta") {
18621863
debug!("looks like metadata finished early!");

0 commit comments

Comments
 (0)