Skip to content

Commit

Permalink
Rollup merge of #120084 - weihanglo:pkgid-spec, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
fix(rust-analyzer): use new pkgid spec to compare

Starting from rust-lang/cargo#13311, Cargo's compiler artifact message
uses Package ID specification as package's identifier format.

Zulip topic: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/proc-macro-test.20bootstrap.20and.20pkgid.20JSON

cc `@ehuss`
  • Loading branch information
Nadrieril committed Jan 21, 2024
2 parents e7f3dc7 + 9650c30 commit 01669d2
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,24 @@ fn main() {
panic!("proc-macro-test-impl failed to build");
}

// Old Package ID Spec
let repr = format!("{name} {version}");
// New Package Id Spec since rust-lang/cargo#13311
let pkgid = String::from_utf8(
Command::new(toolchain::cargo())
.current_dir(&staging_dir)
.args(["pkgid", name])
.output()
.unwrap().stdout,
)
.unwrap();
let pkgid = pkgid.trim();

let mut artifact_path = None;
for message in Message::parse_stream(output.stdout.as_slice()) {
if let Message::CompilerArtifact(artifact) = message.unwrap() {
if artifact.target.kind.contains(&"proc-macro".to_string()) {
let repr = format!("{name} {version}");
if artifact.package_id.repr.starts_with(&repr) {
if artifact.package_id.repr.starts_with(&repr) || artifact.package_id.repr == pkgid {
artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
}
}
Expand Down

0 comments on commit 01669d2

Please sign in to comment.