@@ -404,21 +404,26 @@ fn activate_injected_dep(
404404/// there's only going to be one panic runtime in the output.
405405fn verify_ok ( tcx : TyCtxt < ' _ > , list : & DependencyList ) {
406406 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 ( ) ;
407413 if list. is_empty ( ) {
408414 return ;
409415 }
410416 let desired_strategy = sess. panic_strategy ( ) ;
411417
412418 // If we are panic=immediate-abort, make sure everything in the dependency tree has also been
413419 // 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+ {
415424 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 ) {
422427 invalid_crates. push ( cnum) ;
423428 // If core is incompatible, it's very likely that we'd emit an error for every
424429 // 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) {
435440 }
436441
437442 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 ( ) {
443444 if tcx. is_panic_runtime ( cnum) {
444445 if let Some ( ( prev, _) ) = panic_runtime {
445446 let prev_name = tcx. crate_name ( prev) ;
@@ -472,10 +473,7 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &DependencyList) {
472473 // strategy. If the dep isn't linked, we ignore it, and if our strategy
473474 // is abort then it's compatible with everything. Otherwise all crates'
474475 // 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 ( ) {
479477 if cnum == runtime_cnum || tcx. is_compiler_builtins ( cnum) {
480478 continue ;
481479 }
0 commit comments