@@ -29,7 +29,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
2929use rustc_codegen_ssa:: traits:: * ;
3030use rustc_codegen_ssa:: { ModuleCodegen , ModuleKind , looks_like_rust_object_file} ;
3131use rustc_data_structures:: memmap:: Mmap ;
32- use rustc_errors:: { DiagCtxtHandle , FatalError } ;
32+ use rustc_errors:: DiagCtxtHandle ;
3333use rustc_middle:: bug;
3434use rustc_middle:: dep_graph:: WorkProduct ;
3535use rustc_session:: config:: Lto ;
@@ -51,12 +51,11 @@ fn prepare_lto(
5151 cgcx : & CodegenContext < GccCodegenBackend > ,
5252 each_linked_rlib_for_lto : & [ PathBuf ] ,
5353 dcx : DiagCtxtHandle < ' _ > ,
54- ) -> Result < LtoData , FatalError > {
54+ ) -> LtoData {
5555 let tmp_path = match tempdir ( ) {
5656 Ok ( tmp_path) => tmp_path,
5757 Err ( error) => {
58- eprintln ! ( "Cannot create temporary directory: {}" , error) ;
59- return Err ( FatalError ) ;
58+ dcx. fatal ( format ! ( "Cannot create temporary directory: {}" , error) ) ;
6059 }
6160 } ;
6261
@@ -91,15 +90,14 @@ fn prepare_lto(
9190 upstream_modules. push ( ( module, CString :: new ( name) . unwrap ( ) ) ) ;
9291 }
9392 Err ( e) => {
94- dcx. emit_err ( e) ;
95- return Err ( FatalError ) ;
93+ dcx. emit_fatal ( e) ;
9694 }
9795 }
9896 }
9997 }
10098 }
10199
102- Ok ( LtoData { upstream_modules, tmp_path } )
100+ LtoData { upstream_modules, tmp_path }
103101}
104102
105103fn save_as_file ( obj : & [ u8 ] , path : & Path ) -> Result < ( ) , LtoBitcodeFromRlib > {
@@ -114,10 +112,10 @@ pub(crate) fn run_fat(
114112 cgcx : & CodegenContext < GccCodegenBackend > ,
115113 each_linked_rlib_for_lto : & [ PathBuf ] ,
116114 modules : Vec < FatLtoInput < GccCodegenBackend > > ,
117- ) -> Result < ModuleCodegen < GccContext > , FatalError > {
115+ ) -> ModuleCodegen < GccContext > {
118116 let dcx = cgcx. create_dcx ( ) ;
119117 let dcx = dcx. handle ( ) ;
120- let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ? ;
118+ let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ;
121119 /*let symbols_below_threshold =
122120 lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
123121 fat_lto (
@@ -137,7 +135,7 @@ fn fat_lto(
137135 mut serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
138136 tmp_path : TempDir ,
139137 //symbols_below_threshold: &[String],
140- ) -> Result < ModuleCodegen < GccContext > , FatalError > {
138+ ) -> ModuleCodegen < GccContext > {
141139 let _timer = cgcx. prof . generic_activity ( "GCC_fat_lto_build_monolithic_module" ) ;
142140 info ! ( "going for a fat lto" ) ;
143141
@@ -261,7 +259,7 @@ fn fat_lto(
261259 // of now.
262260 module. module_llvm . temp_dir = Some ( tmp_path) ;
263261
264- Ok ( module)
262+ module
265263}
266264
267265pub struct ModuleBuffer ( PathBuf ) ;
@@ -286,10 +284,10 @@ pub(crate) fn run_thin(
286284 each_linked_rlib_for_lto : & [ PathBuf ] ,
287285 modules : Vec < ( String , ThinBuffer ) > ,
288286 cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
289- ) -> Result < ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) , FatalError > {
287+ ) -> ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) {
290288 let dcx = cgcx. create_dcx ( ) ;
291289 let dcx = dcx. handle ( ) ;
292- let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ? ;
290+ let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ;
293291 if cgcx. opts . cg . linker_plugin_lto . enabled ( ) {
294292 unreachable ! (
295293 "We should never reach this case if the LTO step \
@@ -355,7 +353,7 @@ fn thin_lto(
355353 tmp_path : TempDir ,
356354 cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
357355 //_symbols_below_threshold: &[String],
358- ) -> Result < ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) , FatalError > {
356+ ) -> ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) {
359357 let _timer = cgcx. prof . generic_activity ( "LLVM_thin_lto_global_analysis" ) ;
360358 info ! ( "going for that thin, thin LTO" ) ;
361359
@@ -518,13 +516,13 @@ fn thin_lto(
518516 // TODO: save the directory so that it gets deleted later.
519517 std:: mem:: forget ( tmp_path) ;
520518
521- Ok ( ( opt_jobs, copy_jobs) )
519+ ( opt_jobs, copy_jobs)
522520}
523521
524522pub fn optimize_thin_module (
525523 thin_module : ThinModule < GccCodegenBackend > ,
526524 _cgcx : & CodegenContext < GccCodegenBackend > ,
527- ) -> Result < ModuleCodegen < GccContext > , FatalError > {
525+ ) -> ModuleCodegen < GccContext > {
528526 //let dcx = cgcx.create_dcx();
529527
530528 //let module_name = &thin_module.shared.module_names[thin_module.idx];
@@ -634,7 +632,8 @@ pub fn optimize_thin_module(
634632 save_temp_bitcode(cgcx, &module, "thin-lto-after-pm");
635633 }
636634 }*/
637- Ok ( module)
635+ #[ allow( clippy:: let_and_return) ]
636+ module
638637}
639638
640639pub struct ThinBuffer {
0 commit comments