@@ -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 ;
@@ -452,10 +453,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
452453 let Some ( llfn) = cx. declare_c_main ( llfty) else {
453454 // FIXME: We should be smart and show a better diagnostic here.
454455 let span = cx. tcx ( ) . def_span ( rust_main_def_id) ;
455- cx. sess ( )
456- . struct_span_err ( span, "entry symbol `main` declared multiple times" )
457- . help ( "did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead" )
458- . emit ( ) ;
456+ cx. sess ( ) . emit_err ( errors:: MultipleMainFunctions { span } ) ;
459457 cx. sess ( ) . abort_if_errors ( ) ;
460458 bug ! ( ) ;
461459 } ;
@@ -596,8 +594,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
596594 & metadata,
597595 & exported_symbols:: metadata_symbol_name ( tcx) ,
598596 ) ;
599- if let Err ( err ) = std:: fs:: write ( & file_name, data) {
600- tcx. sess . fatal ( & format ! ( "error writing metadata object file: {}" , err ) ) ;
597+ if let Err ( error ) = std:: fs:: write ( & file_name, data) {
598+ tcx. sess . emit_fatal ( errors :: MetadataObjectFileWrite { error } ) ;
601599 }
602600 Some ( CompiledModule {
603601 name : metadata_cgu_name,
@@ -816,11 +814,7 @@ impl CrateInfo {
816814 let subsystem = tcx. sess . first_attr_value_str_by_name ( crate_attrs, sym:: windows_subsystem) ;
817815 let windows_subsystem = subsystem. map ( |subsystem| {
818816 if subsystem != sym:: windows && subsystem != sym:: console {
819- tcx. sess . fatal ( & format ! (
820- "invalid windows subsystem `{}`, only \
821- `windows` and `console` are allowed",
822- subsystem
823- ) ) ;
817+ tcx. sess . emit_fatal ( errors:: InvalidWindowsSubsystem { subsystem } ) ;
824818 }
825819 subsystem. to_string ( )
826820 } ) ;
0 commit comments