From 5b8b2ac248dca8727c9a10cb8fd6376d9e4f0051 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Fri, 13 Dec 2024 11:00:57 -0600 Subject: [PATCH] fix(base): Support bases in patches in virtual manifests This bug has been there since #14360 --- src/cargo/util/toml/mod.rs | 22 ++++++++++------------ tests/testsuite/patch.rs | 15 +++------------ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 81155915191..bc80097b705 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -304,7 +304,12 @@ fn normalize_toml( lints: None, workspace: original_toml.workspace.clone(), profile: original_toml.profile.clone(), - patch: None, + patch: normalize_patch( + gctx, + original_toml.patch.as_ref(), + &workspace_root, + features, + )?, replace: original_toml.replace.clone(), _unused_keys: Default::default(), }; @@ -483,13 +488,6 @@ fn normalize_toml( } normalized_toml.target = (!normalized_target.is_empty()).then_some(normalized_target); - normalized_toml.patch = normalize_patch( - gctx, - original_toml.patch.as_ref(), - &workspace_root, - features, - )?; - let normalized_lints = original_toml .lints .clone() @@ -1733,14 +1731,14 @@ fn to_virtual_manifest( root, }; ( - replace(&original_toml, &mut manifest_ctx)?, - patch(&original_toml, &mut manifest_ctx)?, + replace(&normalized_toml, &mut manifest_ctx)?, + patch(&normalized_toml, &mut manifest_ctx)?, ) }; - if let Some(profiles) = &original_toml.profile { + if let Some(profiles) = &normalized_toml.profile { validate_profiles(profiles, gctx.cli_unstable(), &features, warnings)?; } - let resolve_behavior = original_toml + let resolve_behavior = normalized_toml .workspace .as_ref() .and_then(|ws| ws.resolver.as_deref()) diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index eb5efd4c33b..ff46b324091 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -3138,18 +3138,9 @@ fn patch_in_virtual_with_base() { p.cargo("tree") .masquerade_as_nightly_cargo(&["path-bases"]) - .with_status(101) - .with_stderr_data(str![[r#" -[ERROR] failed to load source for dependency `bar` - -Caused by: - Unable to update [ROOT]/foo/bar - -Caused by: - failed to read `[ROOT]/foo/bar/Cargo.toml` - -Caused by: - [NOT_FOUND] + .with_stdout_data(str![[r#" +foo v0.5.0 ([ROOT]/foo/foo) +└── bar v0.5.0 ([ROOT]/bar) "#]]) .run();