diff options
| author | Weihang Lo <me@weihanglo.tw> | 2024-01-18 06:50:06 +0000 |
|---|---|---|
| committer | Weihang Lo <whlo@amazon.co.uk> | 2024-01-18 07:01:29 +0000 |
| commit | 9650c30fbb9e3741fbc4d01bc64496f7d725212e (patch) | |
| tree | 77e79cdc3eb07a378b503310c8da3506a3795811 | |
| parent | 6ae4cfbbb080cafea7f6be48ce47678ee057352c (diff) | |
| download | rust-9650c30fbb9e3741fbc4d01bc64496f7d725212e.tar.gz rust-9650c30fbb9e3741fbc4d01bc64496f7d725212e.zip | |
fix(rust-analyzer): use new pkgid spec to compare
Starting from cargo#13311, Cargo's compiler artifact message uses Package ID specification as package's identifier format.
| -rw-r--r-- | src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/build.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/build.rs b/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/build.rs index 6cf2b5643e5..e6903fb8d4a 100644 --- a/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/build.rs +++ b/src/tools/rust-analyzer/crates/proc-macro-srv/proc-macro-test/build.rs @@ -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])); } } |
