-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cargo test
doesn't mention which file(s) in examples/ is affected when the main
function is missing
#4948
Comments
Thanks for the report! Can you gist the full error message as well as perhaps an example project to reproduce? |
Extremely simple example: https://github.com/Cobrand/cargo_error_example Just Full error message for
|
Hm ok, isn't this covered by
? |
The error refers to the name of the package, not the name of the example. Put a file There are three things going on here:
Running a second time gives
Notice that there is no warning, no |
One option is to just change the error message (here) to include the crate name. Messages without spans (thus filenames) are very rare, and this is the only one that I think might be confusing. Another example is the lint warning that a crate name should have snake case, but it clearly tells you the name of the crate. Other messages without spans include linker errors and incorrect command-line arguments (presumably the user can figure these out?). |
…tebank Add crate name to "main function not found" error message. Fixes rust-lang#44798 and rust-lang/cargo#4948. I was wondering if it might be cleaner to update the ui tests to add a simple `fn main() {}` for the unrelated tests. Let me know if you would prefer that.
I think this can be closed now that rust-lang/rust#48706 has been merged. |
Great! |
Basically, if you have a lib crate with multiple files in "examples", but one of them doesn't have a main, you get this error when running
cargo test
:But you don't know which file is affected by this error.
It would be better to have an error message that says "main function not found in examples/something.rs".
Note that it may be related to rustc itself, but just in case I opened an issue here as it seemed more fit.
The text was updated successfully, but these errors were encountered: