fix(workspace): reload current manifest only

This commit is contained in:
lemorage 2025-06-05 13:25:04 +02:00
parent f22b84f8d4
commit 304a7a0748
2 changed files with 8 additions and 5 deletions

View File

@ -306,7 +306,7 @@ impl<'gctx> Workspace<'gctx> {
/// This is useful if the workspace has been updated, such as with `cargo
/// fix` modifying the `Cargo.toml` file.
pub fn reload(&self, gctx: &'gctx GlobalContext) -> CargoResult<Workspace<'gctx>> {
let mut ws = Workspace::new(self.root_manifest(), gctx)?;
let mut ws = Workspace::new(&self.current_manifest, gctx)?;
ws.set_resolve_honors_rust_version(Some(self.resolve_honors_rust_version));
ws.set_resolve_feature_unification(self.resolve_feature_unification);
ws.set_requested_lockfile_path(self.requested_lockfile_path.clone());

View File

@ -2719,7 +2719,7 @@ fn nonexistence_package_together_with_workspace() {
// A failing case from <https://github.com/rust-lang/cargo/issues/15625>
#[cargo_test]
fn clippy_fix_all_members_in_a_workspace() {
fn fix_only_check_manifest_path_member() {
let p = project()
.file(
"Cargo.toml",
@ -2751,8 +2751,11 @@ fn clippy_fix_all_members_in_a_workspace() {
.file("bar/src/main.rs", "fn main() {}")
.build();
p.cargo("clippy --manifest-path foo/Cargo.toml --fix --allow-no-vcs")
.with_stderr_contains("[CHECKING] foo v0.1.0 ([ROOT]/foo/foo)")
.with_stderr_contains("[CHECKING] bar v0.1.0 ([ROOT]/foo/bar)")
p.cargo("fix --manifest-path foo/Cargo.toml --allow-no-vcs")
.with_stderr_data(str![[r#"
[CHECKING] foo v0.1.0 ([ROOT]/foo/foo)
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
"#]])
.run();
}