@@ -625,17 +625,37 @@ impl Cfg {
625
625
targets : & [ & str ] ,
626
626
) -> Result < bool > {
627
627
let components_requested = !components. is_empty ( ) || !targets. is_empty ( ) ;
628
-
628
+ // If we're here, the toolchain exists on disk and is a dist toolchain
629
+ // so we should attempt to load its manifest
630
+ let manifest = if let Some ( manifest) = distributable. get_manifest ( ) ? {
631
+ manifest
632
+ } else {
633
+ // If we can't read the manifest we'd best try and install
634
+ return Ok ( true ) ;
635
+ } ;
629
636
match ( distributable. list_components ( ) , components_requested) {
630
637
// If the toolchain does not support components but there were components requested, bubble up the error
631
638
( Err ( e) , true ) => Err ( e) ,
632
- ( Ok ( installed_components) , _) => {
633
- Ok ( components. iter ( ) . chain ( targets. iter ( ) ) . all ( |name| {
634
- installed_components. iter ( ) . any ( |status| {
635
- status. component . short_name_in_manifest ( ) == name && status. installed
639
+ // Otherwise check if all the components we want are installed
640
+ ( Ok ( installed_components) , _) => Ok ( components. iter ( ) . all ( |name| {
641
+ installed_components. iter ( ) . any ( |status| {
642
+ let cname = status. component . short_name ( & manifest) ;
643
+ let cname = cname. as_str ( ) ;
644
+ let cnameim = status. component . short_name_in_manifest ( ) ;
645
+ let cnameim = cnameim. as_str ( ) ;
646
+ ( cname == * name || cnameim == * name) && status. installed
647
+ } )
648
+ } )
649
+ // And that all the targets we want are installed
650
+ && targets. iter ( ) . all ( |name| {
651
+ installed_components
652
+ . iter ( )
653
+ . filter ( |c| c. component . short_name_in_manifest ( ) == "rust-std" )
654
+ . any ( |status| {
655
+ let ctarg = status. component . target ( ) ;
656
+ ( ctarg == * name) && status. installed
636
657
} )
637
- } ) )
638
- }
658
+ } ) ) ,
639
659
_ => Ok ( true ) ,
640
660
}
641
661
}
0 commit comments