Skip to content

Commit

Permalink
fix(base): Support bases in patches in virtual manifests
Browse files Browse the repository at this point in the history
This bug has been there since #14360
  • Loading branch information
epage committed Dec 13, 2024
1 parent 2d23b94 commit 5b8b2ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
22 changes: 10 additions & 12 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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())
Expand Down
15 changes: 3 additions & 12 deletions tests/testsuite/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5b8b2ac

Please sign in to comment.