Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upBetter error message for "[E0601]: main function not found" #44798
Comments
TimNN
added
A-diagnostics
C-enhancement
labels
Sep 24, 2017
This comment has been minimized.
This comment has been minimized.
|
See also, rust-lang/cargo#4948 |
ehuss
added a commit
to ehuss/rust
that referenced
this issue
Mar 3, 2018
ehuss
referenced this issue
Mar 3, 2018
Merged
Add crate name to "main function not found" error message. #48706
This comment has been minimized.
This comment has been minimized.
|
@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 |
This comment has been minimized.
This comment has been minimized.
|
@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. |
This comment has been minimized.
This comment has been minimized.
|
@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. |
djc commentedSep 23, 2017
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.