-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Better error message for "[E0601]: main function not found" #44798
Comments
See also, rust-lang/cargo#4948 |
@ehuss thanks for working on this! The changes in your PR already look this, but I don't think they fully cover the particular case I'm talking about here ("crate with multiple binaries defined") too well (that is, a crate that has a |
@djc it should work, unless I am misunderstanding your situation. From the terminology I've seen, each bin is considered a separate "crate", and a package can have multiple binary crates (rust-lang/cargo#3380). So for a package layout like this:
The corresponding errors for the three binaries would be:
There might be confusion (such as if you have examples with the same name as a binary, or binaries with the same name in separate packages within a workspace). That's why I proposed in the PR to add the exact path to the recommended source file where you should add a main function, but I have not heard back. |
@ehuss, ah, awesome! In this case, I find the wording of "not found in crate" maybe a little confusing, because as far as I understand it, the intention of "crate" is usually to cover the whole thing rather than a single binary included in it. |
…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'm seeing this in a crate with multiple binaries defined, so one important improvement would be to name the binary that is causing the problem. Once I've figured why this error is happening incorrectly in the particular crate that I'm struggling with now, I'll probably have more suggestions.
The text was updated successfully, but these errors were encountered: