@@ -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) ?;
@@ -768,6 +776,7 @@ impl<'a> Cfg<'a> {
768776
769777 // Returns a Toolchain matching the given ToolchainDesc, installing it and
770778 // the given components and targets if they aren't already installed.
779+ #[ allow( clippy:: too_many_arguments) ]
771780 #[ tracing:: instrument( level = "trace" , err( level = "trace" ) , skip_all) ]
772781 pub ( crate ) async fn ensure_installed (
773782 & self ,
@@ -777,6 +786,7 @@ impl<'a> Cfg<'a> {
777786 profile : Option < Profile > ,
778787 force_non_host : bool ,
779788 verbose : bool ,
789+ skip_std : bool ,
780790 ) -> Result < ( UpdateStatus , Toolchain < ' _ > ) > {
781791 common:: check_non_host_toolchain (
782792 toolchain. to_string ( ) ,
@@ -800,6 +810,7 @@ impl<'a> Cfg<'a> {
800810 false ,
801811 self ,
802812 ) ?;
813+ options. skip_std = skip_std;
803814
804815 let ( status, toolchain) = match DistributableToolchain :: new ( self , toolchain. clone ( ) ) {
805816 Err ( RustupError :: ToolchainNotInstalled { .. } ) => {
@@ -1030,6 +1041,7 @@ mod tests {
10301041 components: None ,
10311042 targets: None ,
10321043 profile: None ,
1044+ skip_std: None ,
10331045 }
10341046 }
10351047 ) ;
@@ -1057,6 +1069,7 @@ profile = "default"
10571069 "thumbv2-none-eabi" . into( )
10581070 ] ) ,
10591071 profile: Some ( "default" . into( ) ) ,
1072+ skip_std: None ,
10601073 }
10611074 }
10621075 ) ;
@@ -1078,6 +1091,7 @@ channel = "nightly-2020-07-10"
10781091 components: None ,
10791092 targets: None ,
10801093 profile: None ,
1094+ skip_std: None ,
10811095 }
10821096 }
10831097 ) ;
@@ -1099,6 +1113,7 @@ path = "foobar"
10991113 components: None ,
11001114 targets: None ,
11011115 profile: None ,
1116+ skip_std: None ,
11021117 }
11031118 }
11041119 ) ;
@@ -1121,6 +1136,7 @@ components = []
11211136 components: Some ( vec![ ] ) ,
11221137 targets: None ,
11231138 profile: None ,
1139+ skip_std: None ,
11241140 }
11251141 }
11261142 ) ;
@@ -1143,6 +1159,7 @@ targets = []
11431159 components: None ,
11441160 targets: Some ( vec![ ] ) ,
11451161 profile: None ,
1162+ skip_std: None ,
11461163 }
11471164 }
11481165 ) ;
@@ -1164,6 +1181,7 @@ components = [ "rustfmt" ]
11641181 components: Some ( vec![ "rustfmt" . into( ) ] ) ,
11651182 targets: None ,
11661183 profile: None ,
1184+ skip_std: None ,
11671185 }
11681186 }
11691187 ) ;
@@ -1216,4 +1234,27 @@ channel = nightly
12161234 Ok ( OverrideFileConfigError :: Parsing )
12171235 ) ) ;
12181236 }
1237+
1238+ #[ test]
1239+ fn parse_toml_toolchain_file_with_skip_std ( ) {
1240+ let contents = r#"[toolchain]
1241+ channel = "nightly-2020-07-10"
1242+ skip_std = true
1243+ "# ;
1244+
1245+ let result = Cfg :: parse_override_file ( contents, ParseMode :: Both ) ;
1246+ assert_eq ! (
1247+ result. unwrap( ) ,
1248+ OverrideFile {
1249+ toolchain: ToolchainSection {
1250+ channel: Some ( "nightly-2020-07-10" . into( ) ) ,
1251+ path: None ,
1252+ components: None ,
1253+ targets: None ,
1254+ profile: None ,
1255+ skip_std: Some ( true ) ,
1256+ }
1257+ }
1258+ ) ;
1259+ }
12191260}
0 commit comments