Skip to content

Commit 01669d2

Browse files
authored
Rollup merge of rust-lang#120084 - weihanglo:pkgid-spec, r=Mark-Simulacrum
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`
2 parents e7f3dc7 + 9650c30 commit 01669d2

File tree

1 file changed

+14
-2
lines changed
  • src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test

1 file changed

+14
-2
lines changed

src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/build.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,24 @@ fn main() {
9292
panic!("proc-macro-test-impl failed to build");
9393
}
9494

95+
// Old Package ID Spec
96+
let repr = format!("{name} {version}");
97+
// New Package Id Spec since rust-lang/cargo#13311
98+
let pkgid = String::from_utf8(
99+
Command::new(toolchain::cargo())
100+
.current_dir(&staging_dir)
101+
.args(["pkgid", name])
102+
.output()
103+
.unwrap().stdout,
104+
)
105+
.unwrap();
106+
let pkgid = pkgid.trim();
107+
95108
let mut artifact_path = None;
96109
for message in Message::parse_stream(output.stdout.as_slice()) {
97110
if let Message::CompilerArtifact(artifact) = message.unwrap() {
98111
if artifact.target.kind.contains(&"proc-macro".to_string()) {
99-
let repr = format!("{name} {version}");
100-
if artifact.package_id.repr.starts_with(&repr) {
112+
if artifact.package_id.repr.starts_with(&repr) || artifact.package_id.repr == pkgid {
101113
artifact_path = Some(PathBuf::from(&artifact.filenames[0]));
102114
}
103115
}

0 commit comments

Comments
 (0)