Uh oh!
There was an error while loading. Please reload this page.
Add crate name to "main function not found" error message. - #48706
Conversation
rust-highfive
commented
Mar 3, 2018
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @estebank (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
estebank
commented
Mar 3, 2018
In general, yes, I prefer to add an empty As for the change, I think there'd be value in having the path of the file we're looking for the method in a note as well, but don't know how hard that'd be to add. What do you think @ehuss? |
ehuss
commented
Mar 3, 2018
I'm not entirely certain which situations --- a/src/librustc/middle/entry.rs+++ b/src/librustc/middle/entry.rs@@ -178,6 +178,9 @@ fn configure_main(this: &mut EntryContext, crate_name: &str) {
err.emit();
this.session.abort_if_errors();
} else {
+ if let Some(ref filename) = this.session.local_crate_source_file {+ err.note(&format!("consider adding a main function to {}", filename.display()));+ }
if this.session.teach(&err.get_code().unwrap()) {
err.note("If you don't know the basics of Rust, you can go look to the Rust Book \
to get started: https://doc.rust-lang.org/book/");which would render as: |
emilyalbini
commented
Mar 12, 2018
estebank
commented
Mar 12, 2018
@ehuss that seems like what I had in mind. Go ahead and add it to the PR. r=me once it's done. |
02f46bb to
ab4161fCompareehuss
commented
Mar 13, 2018
Thanks @estebank, I have updated it with the new text, updated the tests as discussed, and added a specific test for E0601. |
There was a problem hiding this comment.
Nit: can this be using backticks? e.g.,
`main` function to `{}`
There was a problem hiding this comment.
Nit: backticks please :)
`main` function not found in crate `{}`
nikomatsakis
commented
Mar 13, 2018
@ehuss nice PR =) left a few nits of my own |
ehuss
commented
Mar 13, 2018
Updated, thanks @nikomatsakis! |
estebank
commented
Mar 13, 2018
@bors r+ rollup |
bors
commented
Mar 13, 2018
📌 Commit 2c07c2d has been approved by |
bors
commented
Mar 14, 2018
☔ The latest upstream changes (presumably #48684) made this pull request unmergeable. Please resolve the merge conflicts. |
2c07c2d to
2f1b34cCompareestebank
commented
Mar 14, 2018
@bors r+ |
bors
commented
Mar 14, 2018
📌 Commit 5257275 has been approved by |
…tebank Add crate name to "main function not found" error message. Fixesrust-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.
Fixes#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.