Skip to content

Commit 5b8b2ac

Browse files
committed
fix(base): Support bases in patches in virtual manifests
This bug has been there since #14360
1 parent 2d23b94 commit 5b8b2ac

File tree

2 files changed

+13
-24
lines changed

2 files changed

+13
-24
lines changed

src/cargo/util/toml/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,12 @@ fn normalize_toml(
304304
lints: None,
305305
workspace: original_toml.workspace.clone(),
306306
profile: original_toml.profile.clone(),
307-
patch: None,
307+
patch: normalize_patch(
308+
gctx,
309+
original_toml.patch.as_ref(),
310+
&workspace_root,
311+
features,
312+
)?,
308313
replace: original_toml.replace.clone(),
309314
_unused_keys: Default::default(),
310315
};
@@ -483,13 +488,6 @@ fn normalize_toml(
483488
}
484489
normalized_toml.target = (!normalized_target.is_empty()).then_some(normalized_target);
485490

486-
normalized_toml.patch = normalize_patch(
487-
gctx,
488-
original_toml.patch.as_ref(),
489-
&workspace_root,
490-
features,
491-
)?;
492-
493491
let normalized_lints = original_toml
494492
.lints
495493
.clone()
@@ -1733,14 +1731,14 @@ fn to_virtual_manifest(
17331731
root,
17341732
};
17351733
(
1736-
replace(&original_toml, &mut manifest_ctx)?,
1737-
patch(&original_toml, &mut manifest_ctx)?,
1734+
replace(&normalized_toml, &mut manifest_ctx)?,
1735+
patch(&normalized_toml, &mut manifest_ctx)?,
17381736
)
17391737
};
1740-
if let Some(profiles) = &original_toml.profile {
1738+
if let Some(profiles) = &normalized_toml.profile {
17411739
validate_profiles(profiles, gctx.cli_unstable(), &features, warnings)?;
17421740
}
1743-
let resolve_behavior = original_toml
1741+
let resolve_behavior = normalized_toml
17441742
.workspace
17451743
.as_ref()
17461744
.and_then(|ws| ws.resolver.as_deref())

tests/testsuite/patch.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3138,18 +3138,9 @@ fn patch_in_virtual_with_base() {
31383138

31393139
p.cargo("tree")
31403140
.masquerade_as_nightly_cargo(&["path-bases"])
3141-
.with_status(101)
3142-
.with_stderr_data(str![[r#"
3143-
[ERROR] failed to load source for dependency `bar`
3144-
3145-
Caused by:
3146-
Unable to update [ROOT]/foo/bar
3147-
3148-
Caused by:
3149-
failed to read `[ROOT]/foo/bar/Cargo.toml`
3150-
3151-
Caused by:
3152-
[NOT_FOUND]
3141+
.with_stdout_data(str![[r#"
3142+
foo v0.5.0 ([ROOT]/foo/foo)
3143+
└── bar v0.5.0 ([ROOT]/bar)
31533144
31543145
"#]])
31553146
.run();

0 commit comments

Comments
 (0)