Avoid panicking when Cargo.toml is not present
#4643
Merged
+5
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Hello!
This is my first contribution here to Miri, and hopefully the first of many! :)
When running
cargo clippyin a directory that does not contain aCargo.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 aCargo.tomlcurrently 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 incargo(see here), but that would require addinganyhowas a dependency tocargo-miri. Since we already have ashow_error!macro available, I believe it might be better to use that instead.Thank you in advance for your time and input!