Improve error messages for commonly wrongly-defined target locations #9117
Labels
A-cargo-targets
Area: selection and definition of targets (lib, bins, examples, tests, benches)
A-diagnostics
Area: Error and warning messages generated by Cargo itself.
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
The issue is that specifying a bench target like this in
Cargo.toml
:And you place the file in
bench/mybench.rs
, that it returns a confusing error message. The expected location isbenches/mybench.rs
.I think there are two parts to improve the message here:
path
is not specified, the error message could include the implicit path in the message, maybe something like this:2. If
path
is not specified, but there is a file found at a "commonly wrong location" likebench/<name>.rs
, there could be a note attached suggesting renaming the directory as another option to fix it.It would be nice if these better error messages worked for all of the target types (
test
→tests
andexample
→examples
and maybesrc/bins
→src/bin
).Originally posted by @ehuss in #9014 (comment)
Point
1.
and the final suggestion of extending the behavior to all the target types was addressed in #9116.This issue is specifically focused in
2.
s suggestion of checking "commonly wrong location" to improve the error output.The text was updated successfully, but these errors were encountered: