Skip to content

Conversation

@FranciscoTGouveia
Copy link
Contributor

Hello!
This is my first contribution here to Miri, and hopefully the first of many! :)

When running cargo clippy in a directory that does not contain a Cargo.toml, it displays an informative message such as:
could not find Cargo.toml in [dir] or any parent directory.

In contrast, running cargo miri [test|run] without a Cargo.toml currently causes a panic.
While it is expected that this command should fail, a more user-friendly behavior, similar to clippy, would be to print a descriptive error message instead of panicking.

I'd appreciate your feedback on the following:
I was considering simply calling bail! on the error, as done in cargo (see here), but that would require adding anyhow as a dependency to cargo-miri. Since we already have a show_error! macro available, I believe it might be better to use that instead.

Thank you in advance for your time and input!

@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

Thank you for contributing to Miri!
Please remember to not force-push to the PR branch except when you need to rebase due to a conflict or when the reviewer asks you for it.

@rustbot rustbot added the S-waiting-on-review Status: Waiting for a review to complete label Oct 22, 2025
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

View changes since this review

.no_deps()
.other_options(cargo_extra_flags())
.exec()
.unwrap_or_else(|err| show_error!("{}", err))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this error look like?

I am wondering if we should add something like "cargo metadata failed:\n{}" or so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message currently looks like this:

fatal error: `cargo metadata` exited with an error: error: could not find `Cargo.toml` in `/home/ftg` or any parent directory

For a visual comparison, an image of the previous and current behavior is available below:

image

Apologies for not including this information when I initially opened the PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! And no worries. :)

That does sound a bit redundant, but the message seems to be entirely controlled by cargo_metadata, and it's definitely a big step up from before, so -- LGTM.

@RalfJung RalfJung added this pull request to the merge queue Oct 23, 2025
Merged via the queue into rust-lang:master with commit d88cfbc Oct 23, 2025
13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Waiting for a review to complete label Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants