@@ -56,6 +56,7 @@ struct ToolchainSection {
5656 components : Option < Vec < String > > ,
5757 targets : Option < Vec < String > > ,
5858 profile : Option < String > ,
59+ skip_std : Option < bool > ,
5960}
6061
6162impl ToolchainSection {
@@ -64,6 +65,7 @@ impl ToolchainSection {
6465 && self . components . is_none ( )
6566 && self . targets . is_none ( )
6667 && self . path . is_none ( )
68+ && self . skip_std . is_none ( )
6769 }
6870}
6971
@@ -137,6 +139,7 @@ enum OverrideCfg {
137139 components : Vec < String > ,
138140 targets : Vec < String > ,
139141 profile : Option < Profile > ,
142+ skip_std : bool ,
140143 } ,
141144}
142145
@@ -180,6 +183,7 @@ impl OverrideCfg {
180183 ToolchainName :: Official ( desc) => {
181184 let components = file. toolchain . components . unwrap_or_default ( ) ;
182185 let targets = file. toolchain . targets . unwrap_or_default ( ) ;
186+
183187 Self :: Official {
184188 toolchain : desc,
185189 components,
@@ -190,6 +194,7 @@ impl OverrideCfg {
190194 . as_deref ( )
191195 . map ( Profile :: from_str)
192196 . transpose ( ) ?,
197+ skip_std : file. toolchain . skip_std . unwrap_or ( false ) ,
193198 }
194199 }
195200 ToolchainName :: Custom ( name) => Self :: Custom ( name) ,
@@ -213,6 +218,7 @@ impl From<ToolchainName> for OverrideCfg {
213218 components : vec ! [ ] ,
214219 targets : vec ! [ ] ,
215220 profile : None ,
221+ skip_std : false ,
216222 } ,
217223 ToolchainName :: Custom ( name) => Self :: Custom ( name) ,
218224 }
@@ -737,6 +743,7 @@ impl<'a> Cfg<'a> {
737743 components,
738744 targets,
739745 profile,
746+ skip_std,
740747 } = override_config
741748 {
742749 self . ensure_installed (
@@ -746,6 +753,7 @@ impl<'a> Cfg<'a> {
746753 profile,
747754 force_non_host,
748755 verbose,
756+ skip_std,
749757 )
750758 . await ?;
751759 } else {
@@ -755,7 +763,7 @@ impl<'a> Cfg<'a> {
755763 } else if let Some ( toolchain) = self . get_default ( ) ? {
756764 let source = ActiveSource :: Default ;
757765 if let ToolchainName :: Official ( desc) = & toolchain {
758- self . ensure_installed ( desc, vec ! [ ] , vec ! [ ] , None , force_non_host, verbose)
766+ self . ensure_installed ( desc, vec ! [ ] , vec ! [ ] , None , force_non_host, verbose, false )
759767 . await ?;
760768 } else {
761769 Toolchain :: with_source ( self , toolchain. clone ( ) . into ( ) , & source) ?;
@@ -777,6 +785,7 @@ impl<'a> Cfg<'a> {
777785 profile : Option < Profile > ,
778786 force_non_host : bool ,
779787 verbose : bool ,
788+ skip_std : bool ,
780789 ) -> Result < ( UpdateStatus , Toolchain < ' _ > ) > {
781790 common:: check_non_host_toolchain (
782791 toolchain. to_string ( ) ,
@@ -800,6 +809,7 @@ impl<'a> Cfg<'a> {
800809 false ,
801810 self ,
802811 ) ?;
812+ options. skip_std = skip_std;
803813
804814 let ( status, toolchain) = match DistributableToolchain :: new ( self , toolchain. clone ( ) ) {
805815 Err ( RustupError :: ToolchainNotInstalled { .. } ) => {
@@ -1030,6 +1040,7 @@ mod tests {
10301040 components: None ,
10311041 targets: None ,
10321042 profile: None ,
1043+ skip_std: None ,
10331044 }
10341045 }
10351046 ) ;
@@ -1057,6 +1068,7 @@ profile = "default"
10571068 "thumbv2-none-eabi" . into( )
10581069 ] ) ,
10591070 profile: Some ( "default" . into( ) ) ,
1071+ skip_std: None ,
10601072 }
10611073 }
10621074 ) ;
@@ -1078,6 +1090,7 @@ channel = "nightly-2020-07-10"
10781090 components: None ,
10791091 targets: None ,
10801092 profile: None ,
1093+ skip_std: None ,
10811094 }
10821095 }
10831096 ) ;
@@ -1099,6 +1112,7 @@ path = "foobar"
10991112 components: None ,
11001113 targets: None ,
11011114 profile: None ,
1115+ skip_std: None ,
11021116 }
11031117 }
11041118 ) ;
@@ -1121,6 +1135,7 @@ components = []
11211135 components: Some ( vec![ ] ) ,
11221136 targets: None ,
11231137 profile: None ,
1138+ skip_std: None ,
11241139 }
11251140 }
11261141 ) ;
@@ -1143,6 +1158,7 @@ targets = []
11431158 components: None ,
11441159 targets: Some ( vec![ ] ) ,
11451160 profile: None ,
1161+ skip_std: None ,
11461162 }
11471163 }
11481164 ) ;
@@ -1164,6 +1180,7 @@ components = [ "rustfmt" ]
11641180 components: Some ( vec![ "rustfmt" . into( ) ] ) ,
11651181 targets: None ,
11661182 profile: None ,
1183+ skip_std: None ,
11671184 }
11681185 }
11691186 ) ;
@@ -1216,4 +1233,27 @@ channel = nightly
12161233 Ok ( OverrideFileConfigError :: Parsing )
12171234 ) ) ;
12181235 }
1236+
1237+ #[ test]
1238+ fn parse_toml_toolchain_file_with_skip_std ( ) {
1239+ let contents = r#"[toolchain]
1240+ channel = "nightly-2020-07-10"
1241+ skip_std = true
1242+ "# ;
1243+
1244+ let result = Cfg :: parse_override_file ( contents, ParseMode :: Both ) ;
1245+ assert_eq ! (
1246+ result. unwrap( ) ,
1247+ OverrideFile {
1248+ toolchain: ToolchainSection {
1249+ channel: Some ( "nightly-2020-07-10" . into( ) ) ,
1250+ path: None ,
1251+ components: None ,
1252+ targets: None ,
1253+ profile: None ,
1254+ skip_std: Some ( true ) ,
1255+ }
1256+ }
1257+ ) ;
1258+ }
12191259}
0 commit comments