@@ -22,7 +22,7 @@ use crate::core::build_steps::compile::CODEGEN_BACKEND_PREFIX;
22
22
use crate :: core:: build_steps:: llvm;
23
23
pub use crate :: core:: config:: flags:: Subcommand ;
24
24
use crate :: core:: config:: flags:: { Color , Flags , Warnings } ;
25
- use crate :: utils:: cache:: { Interned , INTERNER } ;
25
+ use crate :: utils:: cache:: Interned ;
26
26
use crate :: utils:: channel:: { self , GitInfo } ;
27
27
use crate :: utils:: helpers:: { self , exe, output, t} ;
28
28
@@ -446,15 +446,21 @@ impl std::str::FromStr for RustcLto {
446
446
}
447
447
}
448
448
449
- #[ derive( Copy , Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
449
+ #[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
450
450
// N.B.: This type is used everywhere, and the entire codebase relies on it being Copy.
451
451
// Making !Copy is highly nontrivial!
452
452
pub struct TargetSelection {
453
- pub triple : Interned < String > ,
454
- file : Option < Interned < String > > ,
453
+ pub triple : Interned < str > ,
454
+ file : Option < Interned < str > > ,
455
455
synthetic : bool ,
456
456
}
457
457
458
+ impl Default for TargetSelection {
459
+ fn default ( ) -> Self {
460
+ Self { triple : "" . into ( ) , file : Default :: default ( ) , synthetic : Default :: default ( ) }
461
+ }
462
+ }
463
+
458
464
/// Newtype over `Vec<TargetSelection>` so we can implement custom parsing logic
459
465
#[ derive( Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
460
466
pub struct TargetSelectionList ( Vec < TargetSelection > ) ;
@@ -481,18 +487,14 @@ impl TargetSelection {
481
487
( selection, None )
482
488
} ;
483
489
484
- let triple = INTERNER . intern_str ( triple ) ;
485
- let file = file. map ( |f| INTERNER . intern_str ( f ) ) ;
490
+ let triple: Interned < str > = triple . into ( ) ;
491
+ let file: Option < Interned < str > > = file. map ( |f| f . into ( ) ) ;
486
492
487
493
Self { triple, file, synthetic : false }
488
494
}
489
495
490
496
pub fn create_synthetic ( triple : & str , file : & str ) -> Self {
491
- Self {
492
- triple : INTERNER . intern_str ( triple) ,
493
- file : Some ( INTERNER . intern_str ( file) ) ,
494
- synthetic : true ,
495
- }
497
+ Self { triple : triple. into ( ) , file : Some ( file. into ( ) ) , synthetic : true }
496
498
}
497
499
498
500
pub fn rustc_target_arg ( & self ) -> & str {
@@ -552,15 +554,15 @@ impl fmt::Debug for TargetSelection {
552
554
553
555
impl PartialEq < & str > for TargetSelection {
554
556
fn eq ( & self , other : & & str ) -> bool {
555
- self . triple == * other
557
+ & * self . triple == * other
556
558
}
557
559
}
558
560
559
561
// Targets are often used as directory names throughout bootstrap.
560
562
// This impl makes it more ergonomics to use them as such.
561
563
impl AsRef < Path > for TargetSelection {
562
564
fn as_ref ( & self ) -> & Path {
563
- self . triple . as_ref ( )
565
+ ( * self . triple ) . as_ref ( )
564
566
}
565
567
}
566
568
@@ -2067,7 +2069,7 @@ impl Config {
2067
2069
// thus, disabled
2068
2070
// - similarly, lld will not be built nor used by default when explicitly asked not to, e.g.
2069
2071
// when the config sets `rust.lld = false`
2070
- if config. build . triple == "x86_64-unknown-linux-gnu"
2072
+ if & * config. build . triple == "x86_64-unknown-linux-gnu"
2071
2073
&& config. hosts == [ config. build ]
2072
2074
&& ( config. channel == "dev" || config. channel == "nightly" )
2073
2075
{
0 commit comments