From fc25d9d9ce25642625a0315751e52f033576dded Mon Sep 17 00:00:00 2001 From: Rustin170506 Date: Thu, 2 Jan 2025 23:13:29 +0800 Subject: [PATCH] feat: use full URL for embedded script paths Signed-off-by: Rustin170506 --- src/cargo/core/workspace.rs | 5 ++++- tests/testsuite/script.rs | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index a81c6b9304e..55db0e913a8 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -1800,7 +1800,10 @@ impl<'gctx> Packages<'gctx> { match self.packages.entry(key.to_path_buf()) { Entry::Occupied(e) => Ok(e.into_mut()), Entry::Vacant(v) => { - let source_id = SourceId::for_path(key)?; + let source_id = match crate::util::toml::is_embedded(manifest_path) { + true => SourceId::for_path(manifest_path)?, + false => SourceId::for_path(key)?, + }; let manifest = read_manifest(manifest_path, source_id, self.gctx)?; Ok(v.insert(match manifest { EitherManifest::Real(manifest) => { diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index 520ebbe556d..49e72f8e579 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -1307,11 +1307,10 @@ fn cmd_pkgid_with_embedded() { .masquerade_as_nightly_cargo(&["script"]) .run(); - // FIXME: It should be `path+[ROOTURL]/foo/script.rs#script@0.0.0`. p.cargo("-Zscript pkgid --manifest-path script.rs") .masquerade_as_nightly_cargo(&["script"]) .with_stdout_data(str![[r#" -path+[ROOTURL]/foo#script@0.0.0 +path+[ROOTURL]/foo/script.rs#script@0.0.0 "#]]) .with_stderr_data(str![[r#"