@@ -5,6 +5,7 @@ use crate::back::write::{
5
5
submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType , OngoingCodegen ,
6
6
} ;
7
7
use crate :: common:: { IntPredicate , RealPredicate , TypeKind } ;
8
+ use crate :: errors;
8
9
use crate :: meth;
9
10
use crate :: mir;
10
11
use crate :: mir:: operand:: OperandValue ;
@@ -452,10 +453,7 @@ pub fn maybe_create_entry_wrapper<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
452
453
let Some ( llfn) = cx. declare_c_main ( llfty) else {
453
454
// FIXME: We should be smart and show a better diagnostic here.
454
455
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 } ) ;
459
457
cx. sess ( ) . abort_if_errors ( ) ;
460
458
bug ! ( ) ;
461
459
} ;
@@ -596,8 +594,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
596
594
& metadata,
597
595
& exported_symbols:: metadata_symbol_name ( tcx) ,
598
596
) ;
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 } ) ;
601
599
}
602
600
Some ( CompiledModule {
603
601
name : metadata_cgu_name,
@@ -816,11 +814,7 @@ impl CrateInfo {
816
814
let subsystem = tcx. sess . first_attr_value_str_by_name ( crate_attrs, sym:: windows_subsystem) ;
817
815
let windows_subsystem = subsystem. map ( |subsystem| {
818
816
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 } ) ;
824
818
}
825
819
subsystem. to_string ( )
826
820
} ) ;
0 commit comments