@@ -409,23 +409,24 @@ pub(crate) fn validate_codegen_backends(backends: Vec<String>, section: &str) ->
409409 }
410410 backends
411411}
412+
412413#[ cfg( not( test) ) ]
413- fn default_lld_opt_in_targets ( ) -> & ' static [ & ' static str ] {
414- & [ "x86_64-unknown-linux-gnu" ]
414+ fn default_lld_opt_in_targets ( ) -> Vec < String > {
415+ vec ! [ "x86_64-unknown-linux-gnu" . to_string ( ) ]
415416}
416417
417418#[ cfg( test) ]
418419thread_local ! {
419- static TEST_LLD_OPT_IN_TARGETS : std:: cell:: RefCell <Option <& ' static [ & ' static str ] >> = std:: cell:: RefCell :: new( None ) ;
420+ static TEST_LLD_OPT_IN_TARGETS : std:: cell:: RefCell <Option <Vec < String > >> = std:: cell:: RefCell :: new( None ) ;
420421}
421422
422423#[ cfg( test) ]
423- fn default_lld_opt_in_targets ( ) -> & ' static [ & ' static str ] {
424- TEST_LLD_OPT_IN_TARGETS . with ( |cell| cell. borrow ( ) . unwrap_or ( & [ ] ) )
424+ fn default_lld_opt_in_targets ( ) -> Vec < String > {
425+ TEST_LLD_OPT_IN_TARGETS . with ( |cell| cell. borrow ( ) . clone ( ) ) . unwrap_or_default ( )
425426}
426427
427428#[ cfg( test) ]
428- pub fn with_lld_opt_in_targets < R > ( targets : & ' static [ & ' static str ] , f : impl FnOnce ( ) -> R ) -> R {
429+ pub fn with_lld_opt_in_targets < R > ( targets : Vec < String > , f : impl FnOnce ( ) -> R ) -> R {
429430 TEST_LLD_OPT_IN_TARGETS . with ( |cell| {
430431 let prev = cell. replace ( Some ( targets) ) ;
431432 let result = f ( ) ;
@@ -633,13 +634,13 @@ impl Config {
633634 // thus, disabled
634635 // - similarly, lld will not be built nor used by default when explicitly asked not to, e.g.
635636 // when the config sets `rust.lld = false`
636- if default_lld_opt_in_targets ( ) . contains ( & self . host_target . triple . to_string ( ) . as_str ( ) )
637+ if default_lld_opt_in_targets ( ) . contains ( & self . host_target . triple . to_string ( ) )
637638 && self . hosts == [ self . host_target ]
638639 {
639640 let no_llvm_config = self
640641 . target_config
641642 . get ( & self . host_target )
642- . is_some_and ( |target_config| target_config. llvm_config . is_none ( ) ) ;
643+ . is_none_or ( |target_config| target_config. llvm_config . is_none ( ) ) ;
643644 let enable_lld = self . llvm_from_ci || no_llvm_config;
644645 // Prefer the config setting in case an explicit opt-out is needed.
645646 self . lld_enabled = lld_enabled. unwrap_or ( enable_lld) ;
0 commit comments