@@ -15,7 +15,7 @@ use rustc_ast::CRATE_NODE_ID;
1515use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
1616use rustc_data_structures:: memmap:: Mmap ;
1717use rustc_data_structures:: temp_dir:: MaybeTempDir ;
18- use rustc_errors:: { DiagCtxtHandle , ErrorGuaranteed , FatalError } ;
18+ use rustc_errors:: { DiagCtxtHandle , FatalError } ;
1919use rustc_fs_util:: { fix_windows_verbatim_for_gcc, try_canonicalize} ;
2020use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
2121use rustc_metadata:: fs:: { METADATA_FILENAME , copy_to_stdout, emit_wrapper_file} ;
@@ -71,7 +71,7 @@ pub fn link_binary(
7171 archive_builder_builder : & dyn ArchiveBuilderBuilder ,
7272 codegen_results : CodegenResults ,
7373 outputs : & OutputFilenames ,
74- ) -> Result < ( ) , ErrorGuaranteed > {
74+ ) {
7575 let _timer = sess. timer ( "link_binary" ) ;
7676 let output_metadata = sess. opts . output_types . contains_key ( & OutputType :: Metadata ) ;
7777 let mut tempfiles_for_stdout_output: Vec < PathBuf > = Vec :: new ( ) ;
@@ -119,7 +119,7 @@ pub fn link_binary(
119119 & codegen_results,
120120 RlibFlavor :: Normal ,
121121 & path,
122- ) ?
122+ )
123123 . build ( & out_filename) ;
124124 }
125125 CrateType :: Staticlib => {
@@ -129,7 +129,7 @@ pub fn link_binary(
129129 & codegen_results,
130130 & out_filename,
131131 & path,
132- ) ? ;
132+ ) ;
133133 }
134134 _ => {
135135 link_natively (
@@ -139,7 +139,7 @@ pub fn link_binary(
139139 & out_filename,
140140 & codegen_results,
141141 path. as_ref ( ) ,
142- ) ? ;
142+ ) ;
143143 }
144144 }
145145 if sess. opts . json_artifact_notifications {
@@ -225,8 +225,6 @@ pub fn link_binary(
225225 maybe_remove_temps_from_module ( preserve_objects, preserve_dwarf_objects, module) ;
226226 }
227227 } ) ;
228-
229- Ok ( ( ) )
230228}
231229
232230// Crate type is not passed when calculating the dylibs to include for LTO. In that case all
@@ -298,7 +296,7 @@ fn link_rlib<'a>(
298296 codegen_results : & CodegenResults ,
299297 flavor : RlibFlavor ,
300298 tmpdir : & MaybeTempDir ,
301- ) -> Result < Box < dyn ArchiveBuilder + ' a > , ErrorGuaranteed > {
299+ ) -> Box < dyn ArchiveBuilder + ' a > {
302300 let mut ab = archive_builder_builder. new_archive_builder ( sess) ;
303301
304302 let trailing_metadata = match flavor {
@@ -374,7 +372,7 @@ fn link_rlib<'a>(
374372 {
375373 let path = find_native_static_library ( filename. as_str ( ) , true , sess) ;
376374 let src = read ( path)
377- . map_err ( |e| sess. dcx ( ) . emit_fatal ( errors:: ReadFileError { message : e } ) ) ? ;
375+ . unwrap_or_else ( |e| sess. dcx ( ) . emit_fatal ( errors:: ReadFileError { message : e } ) ) ;
378376 let ( data, _) = create_wrapper_file ( sess, ".bundled_lib" . to_string ( ) , & src) ;
379377 let wrapper_file = emit_wrapper_file ( sess, & data, tmpdir, filename. as_str ( ) ) ;
380378 packed_bundled_libs. push ( wrapper_file) ;
@@ -392,7 +390,7 @@ fn link_rlib<'a>(
392390 codegen_results. crate_info . used_libraries . iter ( ) ,
393391 tmpdir. as_ref ( ) ,
394392 true ,
395- ) ? {
393+ ) {
396394 ab. add_archive ( & output_path, Box :: new ( |_| false ) ) . unwrap_or_else ( |error| {
397395 sess. dcx ( ) . emit_fatal ( errors:: AddNativeLibrary { library_path : output_path, error } ) ;
398396 } ) ;
@@ -433,7 +431,7 @@ fn link_rlib<'a>(
433431 ab. add_file ( & lib)
434432 }
435433
436- Ok ( ab )
434+ ab
437435}
438436
439437/// Extract all symbols defined in raw-dylib libraries, collated by library name.
@@ -445,7 +443,7 @@ fn link_rlib<'a>(
445443fn collate_raw_dylibs < ' a > (
446444 sess : & Session ,
447445 used_libraries : impl IntoIterator < Item = & ' a NativeLib > ,
448- ) -> Result < Vec < ( String , Vec < DllImport > ) > , ErrorGuaranteed > {
446+ ) -> Vec < ( String , Vec < DllImport > ) > {
449447 // Use index maps to preserve original order of imports and libraries.
450448 let mut dylib_table = FxIndexMap :: < String , FxIndexMap < Symbol , & DllImport > > :: default ( ) ;
451449
@@ -469,15 +467,13 @@ fn collate_raw_dylibs<'a>(
469467 }
470468 }
471469 }
472- if let Some ( guar) = sess. dcx ( ) . has_errors ( ) {
473- return Err ( guar) ;
474- }
475- Ok ( dylib_table
470+ sess. dcx ( ) . abort_if_errors ( ) ;
471+ dylib_table
476472 . into_iter ( )
477473 . map ( |( name, imports) | {
478474 ( name, imports. into_iter ( ) . map ( |( _, import) | import. clone ( ) ) . collect ( ) )
479475 } )
480- . collect ( ) )
476+ . collect ( )
481477}
482478
483479fn create_dll_import_libs < ' a > (
@@ -486,8 +482,8 @@ fn create_dll_import_libs<'a>(
486482 used_libraries : impl IntoIterator < Item = & ' a NativeLib > ,
487483 tmpdir : & Path ,
488484 is_direct_dependency : bool ,
489- ) -> Result < Vec < PathBuf > , ErrorGuaranteed > {
490- Ok ( collate_raw_dylibs ( sess, used_libraries) ?
485+ ) -> Vec < PathBuf > {
486+ collate_raw_dylibs ( sess, used_libraries)
491487 . into_iter ( )
492488 . map ( |( raw_dylib_name, raw_dylib_imports) | {
493489 let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" } ;
@@ -537,7 +533,7 @@ fn create_dll_import_libs<'a>(
537533
538534 output_path
539535 } )
540- . collect ( ) )
536+ . collect ( )
541537}
542538
543539/// Create a static archive.
@@ -557,15 +553,15 @@ fn link_staticlib(
557553 codegen_results : & CodegenResults ,
558554 out_filename : & Path ,
559555 tempdir : & MaybeTempDir ,
560- ) -> Result < ( ) , ErrorGuaranteed > {
556+ ) {
561557 info ! ( "preparing staticlib to {:?}" , out_filename) ;
562558 let mut ab = link_rlib (
563559 sess,
564560 archive_builder_builder,
565561 codegen_results,
566562 RlibFlavor :: StaticlibBase ,
567563 tempdir,
568- ) ? ;
564+ ) ;
569565 let mut all_native_libs = vec ! [ ] ;
570566
571567 let res = each_linked_rlib (
@@ -656,8 +652,6 @@ fn link_staticlib(
656652 print_native_static_libs ( sess, & print. out , & all_native_libs, & all_rust_dylibs) ;
657653 }
658654 }
659-
660- Ok ( ( ) )
661655}
662656
663657/// Use `thorin` (rust implementation of a dwarf packaging utility) to link DWARF objects into a
@@ -773,7 +767,7 @@ fn link_natively(
773767 out_filename : & Path ,
774768 codegen_results : & CodegenResults ,
775769 tmpdir : & Path ,
776- ) -> Result < ( ) , ErrorGuaranteed > {
770+ ) {
777771 info ! ( "preparing {:?} to {:?}" , crate_type, out_filename) ;
778772 let ( linker_path, flavor) = linker_and_flavor ( sess) ;
779773 let self_contained_components = self_contained_components ( sess, crate_type) ;
@@ -797,7 +791,7 @@ fn link_natively(
797791 temp_filename,
798792 codegen_results,
799793 self_contained_components,
800- ) ? ;
794+ ) ;
801795
802796 linker:: disable_localization ( & mut cmd) ;
803797
@@ -1177,8 +1171,6 @@ fn link_natively(
11771171 ab. add_file ( temp_filename) ;
11781172 ab. build ( out_filename) ;
11791173 }
1180-
1181- Ok ( ( ) )
11821174}
11831175
11841176fn strip_symbols_with_external_utility (
@@ -2232,7 +2224,7 @@ fn linker_with_args(
22322224 out_filename : & Path ,
22332225 codegen_results : & CodegenResults ,
22342226 self_contained_components : LinkSelfContainedComponents ,
2235- ) -> Result < Command , ErrorGuaranteed > {
2227+ ) -> Command {
22362228 let self_contained_crt_objects = self_contained_components. is_crt_objects_enabled ( ) ;
22372229 let cmd = & mut * super :: linker:: get_linker (
22382230 sess,
@@ -2356,7 +2348,7 @@ fn linker_with_args(
23562348 codegen_results. crate_info . used_libraries . iter ( ) ,
23572349 tmpdir,
23582350 true ,
2359- ) ? {
2351+ ) {
23602352 cmd. add_object ( & output_path) ;
23612353 }
23622354 // As with add_upstream_native_libraries, we need to add the upstream raw-dylib symbols in case
@@ -2388,7 +2380,7 @@ fn linker_with_args(
23882380 native_libraries_from_nonstatics,
23892381 tmpdir,
23902382 false ,
2391- ) ? {
2383+ ) {
23922384 cmd. add_object ( & output_path) ;
23932385 }
23942386
@@ -2435,7 +2427,7 @@ fn linker_with_args(
24352427 // to it and remove the option. Currently the last holdout is wasm32-unknown-emscripten.
24362428 add_post_link_args ( cmd, sess, flavor) ;
24372429
2438- Ok ( cmd. take_cmd ( ) )
2430+ cmd. take_cmd ( )
24392431}
24402432
24412433fn add_order_independent_options (
0 commit comments