@@ -900,6 +900,8 @@ pub(crate) struct DistOptions<'cfg, 'a> {
900900 components : & ' a [ & ' a str ] ,
901901 /// Extra targets to install from dist
902902 targets : & ' a [ & ' a str ] ,
903+ /// Flag to skip installation of rust-std
904+ pub ( super ) skip_std : bool ,
903905}
904906
905907impl < ' cfg , ' a > DistOptions < ' cfg , ' a > {
@@ -909,6 +911,7 @@ impl<'cfg, 'a> DistOptions<'cfg, 'a> {
909911 toolchain : & ' a ToolchainDesc ,
910912 profile : Profile ,
911913 force : bool ,
914+ skip_std : bool ,
912915 cfg : & ' cfg Cfg < ' cfg > ,
913916 ) -> Result < Self > {
914917 Ok ( Self {
@@ -923,6 +926,7 @@ impl<'cfg, 'a> DistOptions<'cfg, 'a> {
923926 old_date_version : None ,
924927 components,
925928 targets,
929+ skip_std,
926930 } )
927931 }
928932
@@ -1034,6 +1038,7 @@ pub(crate) async fn update_from_dist(
10341038 opts. targets ,
10351039 & mut fetched,
10361040 opts. cfg ,
1041+ opts. skip_std ,
10371042 )
10381043 . await ;
10391044
@@ -1131,6 +1136,7 @@ async fn try_update_from_dist_(
11311136 targets : & [ & str ] ,
11321137 fetched : & mut String ,
11331138 cfg : & Cfg < ' _ > ,
1139+ skip_std : bool ,
11341140) -> Result < Option < String > > {
11351141 let toolchain_str = toolchain. to_string ( ) ;
11361142 let manifestation = Manifestation :: open ( prefix. clone ( ) , toolchain. target . clone ( ) ) ?;
@@ -1165,6 +1171,10 @@ async fn try_update_from_dist_(
11651171
11661172 let mut all_components: HashSet < Component > = profile_components. into_iter ( ) . collect ( ) ;
11671173
1174+ if skip_std {
1175+ all_components. retain ( |c| !c. short_name_in_manifest ( ) . starts_with ( "rust-std" ) ) ;
1176+ }
1177+
11681178 let rust_package = m. get_package ( "rust" ) ?;
11691179 let rust_target_package = rust_package. get_target ( Some ( & toolchain. target . clone ( ) ) ) ?;
11701180
@@ -1188,9 +1198,15 @@ async fn try_update_from_dist_(
11881198 all_components. insert ( component) ;
11891199 }
11901200
1191- for & target in targets {
1192- let triple = TargetTriple :: new ( target) ;
1193- all_components. insert ( Component :: new ( "rust-std" . to_string ( ) , Some ( triple) , false ) ) ;
1201+ if !skip_std {
1202+ for & target in targets {
1203+ let triple = TargetTriple :: new ( target) ;
1204+ all_components. insert ( Component :: new (
1205+ "rust-std" . to_string ( ) ,
1206+ Some ( triple) ,
1207+ false ,
1208+ ) ) ;
1209+ }
11941210 }
11951211
11961212 let mut explicit_add_components: Vec < _ > = all_components. into_iter ( ) . collect ( ) ;
0 commit comments