@@ -35,6 +35,7 @@ struct ToolchainSection {
3535 channel : Option < String > ,
3636 components : Option < Vec < String > > ,
3737 targets : Option < Vec < String > > ,
38+ profile : Option < String > ,
3839}
3940
4041impl ToolchainSection {
@@ -78,6 +79,7 @@ struct OverrideCfg<'a> {
7879 toolchain : Option < Toolchain < ' a > > ,
7980 components : Vec < String > ,
8081 targets : Vec < String > ,
82+ profile : Option < dist:: Profile > ,
8183}
8284
8385impl < ' a > OverrideCfg < ' a > {
@@ -89,6 +91,12 @@ impl<'a> OverrideCfg<'a> {
8991 } ,
9092 components : file. toolchain . components . unwrap_or_default ( ) ,
9193 targets : file. toolchain . targets . unwrap_or_default ( ) ,
94+ profile : file
95+ . toolchain
96+ . profile
97+ . as_deref ( )
98+ . map ( dist:: Profile :: from_str)
99+ . transpose ( ) ?,
92100 } )
93101 }
94102}
@@ -660,13 +668,14 @@ impl Cfg {
660668 }
661669 }
662670
663- if let Some ( ( toolchain, components, targets, reason) ) =
671+ if let Some ( ( toolchain, components, targets, reason, profile ) ) =
664672 match self . find_override_config ( path) ? {
665673 Some ( (
666674 OverrideCfg {
667675 toolchain,
668676 components,
669677 targets,
678+ profile,
670679 } ,
671680 reason,
672681 ) ) => {
@@ -678,11 +687,11 @@ impl Cfg {
678687
679688 toolchain
680689 . or ( default)
681- . map ( |toolchain| ( toolchain, components, targets, Some ( reason) ) )
690+ . map ( |toolchain| ( toolchain, components, targets, Some ( reason) , profile ) )
682691 }
683692 None => self
684693 . find_default ( ) ?
685- . map ( |toolchain| ( toolchain, vec ! [ ] , vec ! [ ] , None ) ) ,
694+ . map ( |toolchain| ( toolchain, vec ! [ ] , vec ! [ ] , None , None ) ) ,
686695 }
687696 {
688697 if toolchain. is_custom ( ) {
@@ -698,7 +707,7 @@ impl Cfg {
698707 let distributable = DistributableToolchain :: new ( & toolchain) ?;
699708 if !toolchain. exists ( ) || !components_exist ( & distributable, & components, & targets) ?
700709 {
701- distributable. install_from_dist ( true , false , & components, & targets) ?;
710+ distributable. install_from_dist ( true , false , & components, & targets, profile ) ?;
702711 }
703712 }
704713
@@ -760,7 +769,7 @@ impl Cfg {
760769 let channels = channels. map ( |( n, t) | {
761770 let st = t. and_then ( |t| {
762771 let distributable = DistributableToolchain :: new ( & t) ?;
763- let st = distributable. install_from_dist ( force_update, false , & [ ] , & [ ] ) ;
772+ let st = distributable. install_from_dist ( force_update, false , & [ ] , & [ ] , None ) ;
764773 if let Err ( ref e) = st {
765774 ( self . notify_handler ) ( Notification :: NonFatalError ( e) ) ;
766775 }
@@ -815,7 +824,7 @@ impl Cfg {
815824 let toolchain = self . get_toolchain ( toolchain, false ) ?;
816825 if install_if_missing && !toolchain. exists ( ) {
817826 let distributable = DistributableToolchain :: new ( & toolchain) ?;
818- distributable. install_from_dist ( true , false , & [ ] , & [ ] ) ?;
827+ distributable. install_from_dist ( true , false , & [ ] , & [ ] , None ) ?;
819828 }
820829
821830 if let Some ( cmd) = self . maybe_do_cargo_fallback ( & toolchain, binary) ? {
@@ -911,6 +920,7 @@ mod tests {
911920 channel: Some ( contents. into( ) ) ,
912921 components: None ,
913922 targets: None ,
923+ profile: None ,
914924 }
915925 }
916926 ) ;
@@ -922,6 +932,7 @@ mod tests {
922932channel = "nightly-2020-07-10"
923933components = [ "rustfmt", "rustc-dev" ]
924934targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
935+ profile = "default"
925936"# ;
926937
927938 let result = Cfg :: parse_override_file ( contents) ;
@@ -935,6 +946,7 @@ targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
935946 "wasm32-unknown-unknown" . into( ) ,
936947 "thumbv2-none-eabi" . into( )
937948 ] ) ,
949+ profile: Some ( "default" . into( ) ) ,
938950 }
939951 }
940952 ) ;
@@ -954,6 +966,7 @@ channel = "nightly-2020-07-10"
954966 channel: Some ( "nightly-2020-07-10" . into( ) ) ,
955967 components: None ,
956968 targets: None ,
969+ profile: None ,
957970 }
958971 }
959972 ) ;
@@ -974,6 +987,7 @@ components = []
974987 channel: Some ( "nightly-2020-07-10" . into( ) ) ,
975988 components: Some ( vec![ ] ) ,
976989 targets: None ,
990+ profile: None ,
977991 }
978992 }
979993 ) ;
@@ -994,6 +1008,7 @@ targets = []
9941008 channel: Some ( "nightly-2020-07-10" . into( ) ) ,
9951009 components: None ,
9961010 targets: Some ( vec![ ] ) ,
1011+ profile: None ,
9971012 }
9981013 }
9991014 ) ;
@@ -1013,6 +1028,7 @@ components = [ "rustfmt" ]
10131028 channel: None ,
10141029 components: Some ( vec![ "rustfmt" . into( ) ] ) ,
10151030 targets: None ,
1031+ profile: None ,
10161032 }
10171033 }
10181034 ) ;
0 commit comments