From ba98b5a226fc05627213aae6559ee7a7ab01f46c Mon Sep 17 00:00:00 2001 From: Ethan Donowitz Date: Tue, 14 Oct 2025 09:28:39 -0400 Subject: [PATCH] bug: Loosen file path requirement for discover command Previously, we were expecting the path passed to `DiscoverArgument::Path` to be path to a file that already exists. However, it's possible that rust-analyzer will invoke us with a path to a not-yet-existing file if the user has opened a new file in their editor but hasn't yet saved. This commit removes the requirement that this path point to a file on disk to improve UX in this situation. --- src/cli.rs | 2 +- src/main.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 1d0eac6..20eda2f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -99,7 +99,7 @@ pub struct CheckArgs { #[derive(PartialEq, Clone, Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub enum DiscoverArgument { - Path(FilePathBuf), + Path(Utf8PathBuf), Buildfile(FilePathBuf), } diff --git a/src/main.rs b/src/main.rs index 4adb0b0..ccfa76e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -248,7 +248,7 @@ fn discover(ctx: &Context, discover_args: DiscoverArgs, manifest_path: FilePath< } fn check(ctx: &Context, command: &'static str, args: CheckArgs) -> Result<()> { - let manifest = find_manifest(args.path)?; + let manifest = find_manifest(args.path.into())?; let message_format = if ctx.is_tty { "--message-format=human" } else if args.disable_color_diagnostics { @@ -281,7 +281,7 @@ fn check(ctx: &Context, command: &'static str, args: CheckArgs) -> Result<()> { } } -fn find_manifest(path: FilePathBuf) -> Result { +fn find_manifest(path: Utf8PathBuf) -> Result { let path = std::path::absolute(&path)?; let Some(parent) = path.parent() else { anyhow::bail!("Invalid path: could not get parent");