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.
This commit is contained in:
Weihang Lo 2024-09-27 17:09:31 -04:00
parent cdba1c7bee
commit d6b740f6f3
No known key found for this signature in database
GPG Key ID: D7DBF189825E82E7

View File

@ -1852,11 +1852,12 @@ fn on_stderr_line_inner(
// Look for a matching directive and inform Cargo internally that a
// metadata file has been produced.
#[derive(serde::Deserialize)]
struct ArtifactNotification {
artifact: String,
struct ArtifactNotification<'a> {
#[serde(borrow)]
artifact: Cow<'a, str>,
}
if let Ok(artifact) = serde_json::from_str::<ArtifactNotification>(compiler_message.get()) {
if let Ok(artifact) = serde_json::from_str::<ArtifactNotification<'_>>(compiler_message.get()) {
trace!("found directive from rustc: `{}`", artifact.artifact);
if artifact.artifact.ends_with(".rmeta") {
debug!("looks like metadata finished early!");