diff --git a/src/cargo/core/workspace.rs b/src/cargo/core/workspace.rs index 4f28a4efb14..57e50ebefee 100644 --- a/src/cargo/core/workspace.rs +++ b/src/cargo/core/workspace.rs @@ -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> { - 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()); diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 707b81a167c..8ae6bc37a01 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -2716,3 +2716,46 @@ fn nonexistence_package_together_with_workspace() { "#]]) .run(); } + +// A failing case from +#[cargo_test] +fn fix_only_check_manifest_path_member() { + let p = project() + .file( + "Cargo.toml", + r#" + [workspace] + members = ["foo", "bar"] + resolver = "3" + "#, + ) + .file( + "foo/Cargo.toml", + r#" + [package] + name = "foo" + version = "0.1.0" + edition = "2021" + "#, + ) + .file("foo/src/main.rs", "fn main() {}") + .file( + "bar/Cargo.toml", + r#" + [package] + name = "bar" + version = "0.1.0" + edition = "2021" + "#, + ) + .file("bar/src/main.rs", "fn main() {}") + .build(); + + 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(); +}