@@ -213,8 +213,8 @@ pub fn unsized_info(
213
213
vtable_ptr. llvm_type ( cx) )
214
214
}
215
215
_ => bug ! ( "unsized_info: invalid unsizing {:?} -> {:?}" ,
216
- source,
217
- target) ,
216
+ source,
217
+ target) ,
218
218
}
219
219
}
220
220
@@ -340,11 +340,11 @@ pub fn cast_shift_expr_rhs(
340
340
}
341
341
342
342
fn cast_shift_rhs < ' ll , F , G > ( op : hir:: BinOpKind ,
343
- lhs : & ' ll Value ,
344
- rhs : & ' ll Value ,
345
- trunc : F ,
346
- zext : G )
347
- -> & ' ll Value
343
+ lhs : & ' ll Value ,
344
+ rhs : & ' ll Value ,
345
+ trunc : F ,
346
+ zext : G )
347
+ -> & ' ll Value
348
348
where F : FnOnce ( & ' ll Value , & ' ll Type ) -> & ' ll Value ,
349
349
G : FnOnce ( & ' ll Value , & ' ll Type ) -> & ' ll Value
350
350
{
@@ -363,8 +363,8 @@ fn cast_shift_rhs<'ll, F, G>(op: hir::BinOpKind,
363
363
if lhs_sz < rhs_sz {
364
364
trunc ( rhs, lhs_llty)
365
365
} else if lhs_sz > rhs_sz {
366
- // FIXME (#1877: If shifting by negative
367
- // values becomes not undefined then this is wrong.
366
+ // FIXME (#1877: If in the future shifting by negative
367
+ // values is no longer undefined then this is wrong.
368
368
zext ( rhs, lhs_llty)
369
369
} else {
370
370
rhs
@@ -495,10 +495,8 @@ pub fn codegen_instance<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, instance: Instance<'
495
495
let sig = common:: ty_fn_sig ( cx, fn_ty) ;
496
496
let sig = cx. tcx . normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & sig) ;
497
497
498
- let lldecl = match cx. instances . borrow ( ) . get ( & instance) {
499
- Some ( & val) => val,
500
- None => bug ! ( "Instance `{:?}` not already declared" , instance)
501
- } ;
498
+ let lldecl = cx. instances . borrow ( ) . get ( & instance) . cloned ( ) . unwrap_or_else ( ||
499
+ bug ! ( "Instance `{:?}` not already declared" , instance) ) ;
502
500
503
501
cx. stats . borrow_mut ( ) . n_closures += 1 ;
504
502
@@ -566,8 +564,8 @@ fn maybe_create_entry_wrapper(cx: &CodegenCx) {
566
564
if declare:: get_defined_value ( cx, "main" ) . is_some ( ) {
567
565
// FIXME: We should be smart and show a better diagnostic here.
568
566
cx. sess ( ) . struct_span_err ( sp, "entry symbol `main` defined multiple times" )
569
- . help ( "did you use #[no_mangle] on `fn main`? Use #[start] instead" )
570
- . emit ( ) ;
567
+ . help ( "did you use #[no_mangle] on `fn main`? Use #[start] instead" )
568
+ . emit ( ) ;
571
569
cx. sess ( ) . abort_if_errors ( ) ;
572
570
bug ! ( ) ;
573
571
}
@@ -736,9 +734,9 @@ fn determine_cgu_reuse<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
736
734
}
737
735
738
736
pub fn codegen_crate < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
739
- rx : mpsc:: Receiver < Box < dyn Any + Send > > )
740
- -> OngoingCodegen {
741
-
737
+ rx : mpsc:: Receiver < Box < dyn Any + Send > > )
738
+ -> OngoingCodegen
739
+ {
742
740
check_for_rustc_errors_attr ( tcx) ;
743
741
744
742
if let Some ( true ) = tcx. sess . opts . debugging_opts . thinlto {
@@ -803,8 +801,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
803
801
804
802
// Run the monomorphization collector and partition the collected items into
805
803
// codegen units.
806
- let codegen_units =
807
- tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) . 1 ;
804
+ let codegen_units = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) . 1 ;
808
805
let codegen_units = ( * codegen_units) . clone ( ) ;
809
806
810
807
// Force all codegen_unit queries so they are already either red or green
@@ -837,12 +834,7 @@ pub fn codegen_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
837
834
. iter ( )
838
835
. any ( |( _, list) | {
839
836
use rustc:: middle:: dependency_format:: Linkage ;
840
- list. iter ( ) . any ( |linkage| {
841
- match linkage {
842
- Linkage :: Dynamic => true ,
843
- _ => false ,
844
- }
845
- } )
837
+ list. iter ( ) . any ( |& linkage| linkage == Linkage :: Dynamic )
846
838
} ) ;
847
839
let allocator_module = if any_dynamic_crate {
848
840
None
@@ -988,7 +980,7 @@ fn collect_and_partition_mono_items<'a, 'tcx>(
988
980
if mode_string != "lazy" {
989
981
let message = format ! ( "Unknown codegen-item collection mode '{}'. \
990
982
Falling back to 'lazy' mode.",
991
- mode_string) ;
983
+ mode_string) ;
992
984
tcx. sess . warn ( & message) ;
993
985
}
994
986
@@ -1123,7 +1115,15 @@ impl CrateInfo {
1123
1115
info. load_wasm_imports ( tcx, LOCAL_CRATE ) ;
1124
1116
}
1125
1117
1126
- for & cnum in tcx. crates ( ) . iter ( ) {
1118
+ let crates = tcx. crates ( ) ;
1119
+
1120
+ let n_crates = crates. len ( ) ;
1121
+ info. native_libraries . reserve ( n_crates) ;
1122
+ info. crate_name . reserve ( n_crates) ;
1123
+ info. used_crate_source . reserve ( n_crates) ;
1124
+ info. missing_lang_items . reserve ( n_crates) ;
1125
+
1126
+ for & cnum in crates. iter ( ) {
1127
1127
info. native_libraries . insert ( cnum, tcx. native_libraries ( cnum) ) ;
1128
1128
info. crate_name . insert ( cnum, tcx. crate_name ( cnum) . to_string ( ) ) ;
1129
1129
info. used_crate_source . insert ( cnum, tcx. used_crate_source ( cnum) ) ;
@@ -1165,11 +1165,12 @@ impl CrateInfo {
1165
1165
}
1166
1166
1167
1167
fn load_wasm_imports ( & mut self , tcx : TyCtxt , cnum : CrateNum ) {
1168
- for ( & id , module ) in tcx. wasm_import_module_map ( cnum) . iter ( ) {
1168
+ self . wasm_imports . extend ( tcx. wasm_import_module_map ( cnum) . iter ( ) . map ( | ( & id , module ) | {
1169
1169
let instance = Instance :: mono ( tcx, id) ;
1170
1170
let import_name = tcx. symbol_name ( instance) ;
1171
- self . wasm_imports . insert ( import_name. to_string ( ) , module. clone ( ) ) ;
1172
- }
1171
+
1172
+ ( import_name. to_string ( ) , module. clone ( ) )
1173
+ } ) ) ;
1173
1174
}
1174
1175
}
1175
1176
0 commit comments