@@ -55,7 +55,9 @@ impl<'a, 'tcx> ItemLikeVisitor<'tcx> for EntryContext<'a, 'tcx> {
5555 }
5656}
5757
58- pub fn find_entry_point ( session : & Session , hir_map : & hir_map:: Map ) {
58+ pub fn find_entry_point ( session : & Session ,
59+ hir_map : & hir_map:: Map ,
60+ crate_name : & str ) {
5961 let any_exe = session. crate_types . borrow ( ) . iter ( ) . any ( |ty| {
6062 * ty == config:: CrateTypeExecutable
6163 } ) ;
@@ -81,7 +83,7 @@ pub fn find_entry_point(session: &Session, hir_map: &hir_map::Map) {
8183
8284 hir_map. krate ( ) . visit_all_item_likes ( & mut ctxt) ;
8385
84- configure_main ( & mut ctxt) ;
86+ configure_main ( & mut ctxt, crate_name ) ;
8587}
8688
8789// Beware, this is duplicated in libsyntax/entry.rs, make sure to keep
@@ -150,7 +152,7 @@ fn find_item(item: &Item, ctxt: &mut EntryContext, at_root: bool) {
150152 }
151153}
152154
153- fn configure_main ( this : & mut EntryContext ) {
155+ fn configure_main ( this : & mut EntryContext , crate_name : & str ) {
154156 if this. start_fn . is_some ( ) {
155157 * this. session . entry_fn . borrow_mut ( ) = this. start_fn ;
156158 this. session . entry_type . set ( Some ( config:: EntryStart ) ) ;
@@ -162,7 +164,8 @@ fn configure_main(this: &mut EntryContext) {
162164 this. session . entry_type . set ( Some ( config:: EntryMain ) ) ;
163165 } else {
164166 // No main function
165- let mut err = struct_err ! ( this. session, E0601 , "main function not found" ) ;
167+ let mut err = struct_err ! ( this. session, E0601 ,
168+ "main function not found in crate {}" , crate_name) ;
166169 if !this. non_main_fns . is_empty ( ) {
167170 // There were some functions named 'main' though. Try to give the user a hint.
168171 err. note ( "the main function must be defined at the crate level \
0 commit comments