From 60638c2902886498a6dc28f3b4ca8ca7d93a9947 Mon Sep 17 00:00:00 2001 From: Maximilian Roos <5635139+max-sixty@users.noreply.github.com> Date: Sat, 4 Jan 2025 15:39:20 -0800 Subject: [PATCH] Defer to `cargo metadata` to evaluate the workspace root (#660) Not a big deal, but I think we can just defer --- cargo-insta/src/cli.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/cargo-insta/src/cli.rs b/cargo-insta/src/cli.rs index 62c92fc1..c91bf395 100644 --- a/cargo-insta/src/cli.rs +++ b/cargo-insta/src/cli.rs @@ -413,9 +413,6 @@ fn handle_target_args<'a>( ) -> Result, Box> { let mut cmd = cargo_metadata::MetadataCommand::new(); - // if a workspace root is provided we first check if it points to a - // `Cargo.toml`. If it does we instead treat it as manifest path. If both - // are provided we fail with an error. match ( target_args.workspace_root.as_deref(), target_args.manifest_path.as_deref(), @@ -429,14 +426,7 @@ fn handle_target_args<'a>( cmd.manifest_path(manifest); } (Some(root), None) => { - // TODO: should we do this ourselves? Probably fine, but are we - // adding anything by not just deferring to cargo? - let assumed_manifest = root.join("Cargo.toml"); - if assumed_manifest.is_file() { - cmd.manifest_path(assumed_manifest); - } else { - cmd.current_dir(root); - } + cmd.current_dir(root); } (None, None) => {} };