@@ -5,6 +5,7 @@ use crate::back::write::{
55 submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType , OngoingCodegen ,
66} ;
77use crate :: common:: { IntPredicate , RealPredicate , TypeKind } ;
8+ use crate :: errors;
89use crate :: meth;
910use crate :: mir;
1011use crate :: mir:: operand:: OperandValue ;
@@ -451,10 +452,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
451452 let Some ( llfn) = cx. declare_c_main ( llfty) else {
452453 // FIXME: We should be smart and show a better diagnostic here.
453454 let span = cx. tcx ( ) . def_span ( rust_main_def_id) ;
454- cx. sess ( )
455- . struct_span_err ( span, "entry symbol `main` declared multiple times" )
456- . help ( "did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead" )
457- . emit ( ) ;
455+ cx. sess ( ) . emit_err ( errors:: MultipleMainFunctions { span } ) ;
458456 cx. sess ( ) . abort_if_errors ( ) ;
459457 bug ! ( ) ;
460458 } ;
@@ -595,8 +593,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
595593 & metadata,
596594 & exported_symbols:: metadata_symbol_name ( tcx) ,
597595 ) ;
598- if let Err ( err ) = std:: fs:: write ( & file_name, data) {
599- tcx. sess . fatal ( & format ! ( "error writing metadata object file: {}" , err ) ) ;
596+ if let Err ( error ) = std:: fs:: write ( & file_name, data) {
597+ tcx. sess . emit_fatal ( errors :: MetadataObjectFileWrite { error } ) ;
600598 }
601599 Some ( CompiledModule {
602600 name : metadata_cgu_name,
@@ -815,11 +813,7 @@ impl CrateInfo {
815813 let subsystem = tcx. sess . first_attr_value_str_by_name ( crate_attrs, sym:: windows_subsystem) ;
816814 let windows_subsystem = subsystem. map ( |subsystem| {
817815 if subsystem != sym:: windows && subsystem != sym:: console {
818- tcx. sess . fatal ( & format ! (
819- "invalid windows subsystem `{}`, only \
820- `windows` and `console` are allowed",
821- subsystem
822- ) ) ;
816+ tcx. sess . emit_fatal ( errors:: InvalidWindowsSubsystem { subsystem } ) ;
823817 }
824818 subsystem. to_string ( )
825819 } ) ;
0 commit comments