@@ -15,7 +15,7 @@ use rustc_ast::CRATE_NODE_ID;
15
15
use rustc_data_structures:: fx:: { FxIndexMap , FxIndexSet } ;
16
16
use rustc_data_structures:: memmap:: Mmap ;
17
17
use rustc_data_structures:: temp_dir:: MaybeTempDir ;
18
- use rustc_errors:: { DiagCtxtHandle , ErrorGuaranteed , FatalError } ;
18
+ use rustc_errors:: { DiagCtxtHandle , FatalError } ;
19
19
use rustc_fs_util:: { fix_windows_verbatim_for_gcc, try_canonicalize} ;
20
20
use rustc_hir:: def_id:: { CrateNum , LOCAL_CRATE } ;
21
21
use rustc_metadata:: fs:: { METADATA_FILENAME , copy_to_stdout, emit_wrapper_file} ;
@@ -71,7 +71,7 @@ pub fn link_binary(
71
71
archive_builder_builder : & dyn ArchiveBuilderBuilder ,
72
72
codegen_results : CodegenResults ,
73
73
outputs : & OutputFilenames ,
74
- ) -> Result < ( ) , ErrorGuaranteed > {
74
+ ) {
75
75
let _timer = sess. timer ( "link_binary" ) ;
76
76
let output_metadata = sess. opts . output_types . contains_key ( & OutputType :: Metadata ) ;
77
77
let mut tempfiles_for_stdout_output: Vec < PathBuf > = Vec :: new ( ) ;
@@ -119,7 +119,7 @@ pub fn link_binary(
119
119
& codegen_results,
120
120
RlibFlavor :: Normal ,
121
121
& path,
122
- ) ?
122
+ )
123
123
. build ( & out_filename) ;
124
124
}
125
125
CrateType :: Staticlib => {
@@ -129,7 +129,7 @@ pub fn link_binary(
129
129
& codegen_results,
130
130
& out_filename,
131
131
& path,
132
- ) ? ;
132
+ ) ;
133
133
}
134
134
_ => {
135
135
link_natively (
@@ -139,7 +139,7 @@ pub fn link_binary(
139
139
& out_filename,
140
140
& codegen_results,
141
141
path. as_ref ( ) ,
142
- ) ? ;
142
+ ) ;
143
143
}
144
144
}
145
145
if sess. opts . json_artifact_notifications {
@@ -225,8 +225,6 @@ pub fn link_binary(
225
225
maybe_remove_temps_from_module ( preserve_objects, preserve_dwarf_objects, module) ;
226
226
}
227
227
} ) ;
228
-
229
- Ok ( ( ) )
230
228
}
231
229
232
230
// 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>(
298
296
codegen_results : & CodegenResults ,
299
297
flavor : RlibFlavor ,
300
298
tmpdir : & MaybeTempDir ,
301
- ) -> Result < Box < dyn ArchiveBuilder + ' a > , ErrorGuaranteed > {
299
+ ) -> Box < dyn ArchiveBuilder + ' a > {
302
300
let mut ab = archive_builder_builder. new_archive_builder ( sess) ;
303
301
304
302
let trailing_metadata = match flavor {
@@ -374,7 +372,7 @@ fn link_rlib<'a>(
374
372
{
375
373
let path = find_native_static_library ( filename. as_str ( ) , true , sess) ;
376
374
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 } ) ) ;
378
376
let ( data, _) = create_wrapper_file ( sess, ".bundled_lib" . to_string ( ) , & src) ;
379
377
let wrapper_file = emit_wrapper_file ( sess, & data, tmpdir, filename. as_str ( ) ) ;
380
378
packed_bundled_libs. push ( wrapper_file) ;
@@ -392,7 +390,7 @@ fn link_rlib<'a>(
392
390
codegen_results. crate_info . used_libraries . iter ( ) ,
393
391
tmpdir. as_ref ( ) ,
394
392
true ,
395
- ) ? {
393
+ ) {
396
394
ab. add_archive ( & output_path, Box :: new ( |_| false ) ) . unwrap_or_else ( |error| {
397
395
sess. dcx ( ) . emit_fatal ( errors:: AddNativeLibrary { library_path : output_path, error } ) ;
398
396
} ) ;
@@ -433,7 +431,7 @@ fn link_rlib<'a>(
433
431
ab. add_file ( & lib)
434
432
}
435
433
436
- Ok ( ab )
434
+ ab
437
435
}
438
436
439
437
/// Extract all symbols defined in raw-dylib libraries, collated by library name.
@@ -445,7 +443,7 @@ fn link_rlib<'a>(
445
443
fn collate_raw_dylibs < ' a > (
446
444
sess : & Session ,
447
445
used_libraries : impl IntoIterator < Item = & ' a NativeLib > ,
448
- ) -> Result < Vec < ( String , Vec < DllImport > ) > , ErrorGuaranteed > {
446
+ ) -> Vec < ( String , Vec < DllImport > ) > {
449
447
// Use index maps to preserve original order of imports and libraries.
450
448
let mut dylib_table = FxIndexMap :: < String , FxIndexMap < Symbol , & DllImport > > :: default ( ) ;
451
449
@@ -469,15 +467,13 @@ fn collate_raw_dylibs<'a>(
469
467
}
470
468
}
471
469
}
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
476
472
. into_iter ( )
477
473
. map ( |( name, imports) | {
478
474
( name, imports. into_iter ( ) . map ( |( _, import) | import. clone ( ) ) . collect ( ) )
479
475
} )
480
- . collect ( ) )
476
+ . collect ( )
481
477
}
482
478
483
479
fn create_dll_import_libs < ' a > (
@@ -486,8 +482,8 @@ fn create_dll_import_libs<'a>(
486
482
used_libraries : impl IntoIterator < Item = & ' a NativeLib > ,
487
483
tmpdir : & Path ,
488
484
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)
491
487
. into_iter ( )
492
488
. map ( |( raw_dylib_name, raw_dylib_imports) | {
493
489
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" } ;
@@ -537,7 +533,7 @@ fn create_dll_import_libs<'a>(
537
533
538
534
output_path
539
535
} )
540
- . collect ( ) )
536
+ . collect ( )
541
537
}
542
538
543
539
/// Create a static archive.
@@ -557,15 +553,15 @@ fn link_staticlib(
557
553
codegen_results : & CodegenResults ,
558
554
out_filename : & Path ,
559
555
tempdir : & MaybeTempDir ,
560
- ) -> Result < ( ) , ErrorGuaranteed > {
556
+ ) {
561
557
info ! ( "preparing staticlib to {:?}" , out_filename) ;
562
558
let mut ab = link_rlib (
563
559
sess,
564
560
archive_builder_builder,
565
561
codegen_results,
566
562
RlibFlavor :: StaticlibBase ,
567
563
tempdir,
568
- ) ? ;
564
+ ) ;
569
565
let mut all_native_libs = vec ! [ ] ;
570
566
571
567
let res = each_linked_rlib (
@@ -656,8 +652,6 @@ fn link_staticlib(
656
652
print_native_static_libs ( sess, & print. out , & all_native_libs, & all_rust_dylibs) ;
657
653
}
658
654
}
659
-
660
- Ok ( ( ) )
661
655
}
662
656
663
657
/// Use `thorin` (rust implementation of a dwarf packaging utility) to link DWARF objects into a
@@ -773,7 +767,7 @@ fn link_natively(
773
767
out_filename : & Path ,
774
768
codegen_results : & CodegenResults ,
775
769
tmpdir : & Path ,
776
- ) -> Result < ( ) , ErrorGuaranteed > {
770
+ ) {
777
771
info ! ( "preparing {:?} to {:?}" , crate_type, out_filename) ;
778
772
let ( linker_path, flavor) = linker_and_flavor ( sess) ;
779
773
let self_contained_components = self_contained_components ( sess, crate_type) ;
@@ -797,7 +791,7 @@ fn link_natively(
797
791
temp_filename,
798
792
codegen_results,
799
793
self_contained_components,
800
- ) ? ;
794
+ ) ;
801
795
802
796
linker:: disable_localization ( & mut cmd) ;
803
797
@@ -1177,8 +1171,6 @@ fn link_natively(
1177
1171
ab. add_file ( temp_filename) ;
1178
1172
ab. build ( out_filename) ;
1179
1173
}
1180
-
1181
- Ok ( ( ) )
1182
1174
}
1183
1175
1184
1176
fn strip_symbols_with_external_utility (
@@ -2232,7 +2224,7 @@ fn linker_with_args(
2232
2224
out_filename : & Path ,
2233
2225
codegen_results : & CodegenResults ,
2234
2226
self_contained_components : LinkSelfContainedComponents ,
2235
- ) -> Result < Command , ErrorGuaranteed > {
2227
+ ) -> Command {
2236
2228
let self_contained_crt_objects = self_contained_components. is_crt_objects_enabled ( ) ;
2237
2229
let cmd = & mut * super :: linker:: get_linker (
2238
2230
sess,
@@ -2356,7 +2348,7 @@ fn linker_with_args(
2356
2348
codegen_results. crate_info . used_libraries . iter ( ) ,
2357
2349
tmpdir,
2358
2350
true ,
2359
- ) ? {
2351
+ ) {
2360
2352
cmd. add_object ( & output_path) ;
2361
2353
}
2362
2354
// 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(
2388
2380
native_libraries_from_nonstatics,
2389
2381
tmpdir,
2390
2382
false ,
2391
- ) ? {
2383
+ ) {
2392
2384
cmd. add_object ( & output_path) ;
2393
2385
}
2394
2386
@@ -2435,7 +2427,7 @@ fn linker_with_args(
2435
2427
// to it and remove the option. Currently the last holdout is wasm32-unknown-emscripten.
2436
2428
add_post_link_args ( cmd, sess, flavor) ;
2437
2429
2438
- Ok ( cmd. take_cmd ( ) )
2430
+ cmd. take_cmd ( )
2439
2431
}
2440
2432
2441
2433
fn add_order_independent_options (
0 commit comments