@@ -404,21 +404,26 @@ fn activate_injected_dep(
404
404
/// there's only going to be one panic runtime in the output.
405
405
fn verify_ok ( tcx : TyCtxt < ' _ > , list : & DependencyList ) {
406
406
let sess = & tcx. sess ;
407
+ let list: Vec < _ > = list
408
+ . iter_enumerated ( )
409
+ . filter_map (
410
+ |( cnum, linkage) | if * linkage == Linkage :: NotLinked { None } else { Some ( cnum) } ,
411
+ )
412
+ . collect ( ) ;
407
413
if list. is_empty ( ) {
408
414
return ;
409
415
}
410
416
let desired_strategy = sess. panic_strategy ( ) ;
411
417
412
418
// If we are panic=immediate-abort, make sure everything in the dependency tree has also been
413
419
// compiled with immediate-abort.
414
- if desired_strategy == PanicStrategy :: ImmediateAbort {
420
+ if list
421
+ . iter ( )
422
+ . any ( |cnum| tcx. required_panic_strategy ( * cnum) == Some ( PanicStrategy :: ImmediateAbort ) )
423
+ {
415
424
let mut invalid_crates = Vec :: new ( ) ;
416
- for ( cnum, linkage) in list. iter_enumerated ( ) {
417
- if let Linkage :: NotLinked = * linkage {
418
- continue ;
419
- }
420
- let found_strategy = tcx. required_panic_strategy ( cnum) ;
421
- if found_strategy != Some ( PanicStrategy :: ImmediateAbort ) {
425
+ for cnum in list. iter ( ) . copied ( ) {
426
+ if tcx. required_panic_strategy ( cnum) != Some ( PanicStrategy :: ImmediateAbort ) {
422
427
invalid_crates. push ( cnum) ;
423
428
// If core is incompatible, it's very likely that we'd emit an error for every
424
429
// sysroot crate, so instead of doing that emit a single fatal error that suggests
@@ -435,11 +440,7 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &DependencyList) {
435
440
}
436
441
437
442
let mut panic_runtime = None ;
438
- for ( cnum, linkage) in list. iter_enumerated ( ) {
439
- if let Linkage :: NotLinked = * linkage {
440
- continue ;
441
- }
442
-
443
+ for cnum in list. iter ( ) . copied ( ) {
443
444
if tcx. is_panic_runtime ( cnum) {
444
445
if let Some ( ( prev, _) ) = panic_runtime {
445
446
let prev_name = tcx. crate_name ( prev) ;
@@ -472,10 +473,7 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &DependencyList) {
472
473
// strategy. If the dep isn't linked, we ignore it, and if our strategy
473
474
// is abort then it's compatible with everything. Otherwise all crates'
474
475
// panic strategy must match our own.
475
- for ( cnum, linkage) in list. iter_enumerated ( ) {
476
- if let Linkage :: NotLinked = * linkage {
477
- continue ;
478
- }
476
+ for cnum in list. iter ( ) . copied ( ) {
479
477
if cnum == runtime_cnum || tcx. is_compiler_builtins ( cnum) {
480
478
continue ;
481
479
}
0 commit comments