Skip to content

Commit 304a7a0

Browse files
committed
fix(workspace): reload current manifest only
1 parent f22b84f commit 304a7a0

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/cargo/core/workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl<'gctx> Workspace<'gctx> {
306306
/// This is useful if the workspace has been updated, such as with `cargo
307307
/// fix` modifying the `Cargo.toml` file.
308308
pub fn reload(&self, gctx: &'gctx GlobalContext) -> CargoResult<Workspace<'gctx>> {
309-
let mut ws = Workspace::new(self.root_manifest(), gctx)?;
309+
let mut ws = Workspace::new(&self.current_manifest, gctx)?;
310310
ws.set_resolve_honors_rust_version(Some(self.resolve_honors_rust_version));
311311
ws.set_resolve_feature_unification(self.resolve_feature_unification);
312312
ws.set_requested_lockfile_path(self.requested_lockfile_path.clone());

tests/testsuite/workspaces.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2719,7 +2719,7 @@ fn nonexistence_package_together_with_workspace() {
27192719

27202720
// A failing case from <https://github.com/rust-lang/cargo/issues/15625>
27212721
#[cargo_test]
2722-
fn clippy_fix_all_members_in_a_workspace() {
2722+
fn fix_only_check_manifest_path_member() {
27232723
let p = project()
27242724
.file(
27252725
"Cargo.toml",
@@ -2751,8 +2751,11 @@ fn clippy_fix_all_members_in_a_workspace() {
27512751
.file("bar/src/main.rs", "fn main() {}")
27522752
.build();
27532753

2754-
p.cargo("clippy --manifest-path foo/Cargo.toml --fix --allow-no-vcs")
2755-
.with_stderr_contains("[CHECKING] foo v0.1.0 ([ROOT]/foo/foo)")
2756-
.with_stderr_contains("[CHECKING] bar v0.1.0 ([ROOT]/foo/bar)")
2754+
p.cargo("fix --manifest-path foo/Cargo.toml --allow-no-vcs")
2755+
.with_stderr_data(str![[r#"
2756+
[CHECKING] foo v0.1.0 ([ROOT]/foo/foo)
2757+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2758+
2759+
"#]])
27572760
.run();
27582761
}

0 commit comments

Comments
 (0)