@@ -35,6 +35,7 @@ struct ToolchainSection {
35
35
channel : Option < String > ,
36
36
components : Option < Vec < String > > ,
37
37
targets : Option < Vec < String > > ,
38
+ profile : Option < String > ,
38
39
}
39
40
40
41
impl ToolchainSection {
@@ -78,6 +79,7 @@ struct OverrideCfg<'a> {
78
79
toolchain : Option < Toolchain < ' a > > ,
79
80
components : Vec < String > ,
80
81
targets : Vec < String > ,
82
+ profile : Option < dist:: Profile > ,
81
83
}
82
84
83
85
impl < ' a > OverrideCfg < ' a > {
@@ -89,6 +91,12 @@ impl<'a> OverrideCfg<'a> {
89
91
} ,
90
92
components : file. toolchain . components . unwrap_or_default ( ) ,
91
93
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 ( ) ?,
92
100
} )
93
101
}
94
102
}
@@ -660,13 +668,14 @@ impl Cfg {
660
668
}
661
669
}
662
670
663
- if let Some ( ( toolchain, components, targets, reason) ) =
671
+ if let Some ( ( toolchain, components, targets, reason, profile ) ) =
664
672
match self . find_override_config ( path) ? {
665
673
Some ( (
666
674
OverrideCfg {
667
675
toolchain,
668
676
components,
669
677
targets,
678
+ profile,
670
679
} ,
671
680
reason,
672
681
) ) => {
@@ -678,11 +687,11 @@ impl Cfg {
678
687
679
688
toolchain
680
689
. or ( default)
681
- . map ( |toolchain| ( toolchain, components, targets, Some ( reason) ) )
690
+ . map ( |toolchain| ( toolchain, components, targets, Some ( reason) , profile ) )
682
691
}
683
692
None => self
684
693
. find_default ( ) ?
685
- . map ( |toolchain| ( toolchain, vec ! [ ] , vec ! [ ] , None ) ) ,
694
+ . map ( |toolchain| ( toolchain, vec ! [ ] , vec ! [ ] , None , None ) ) ,
686
695
}
687
696
{
688
697
if toolchain. is_custom ( ) {
@@ -698,7 +707,7 @@ impl Cfg {
698
707
let distributable = DistributableToolchain :: new ( & toolchain) ?;
699
708
if !toolchain. exists ( ) || !components_exist ( & distributable, & components, & targets) ?
700
709
{
701
- distributable. install_from_dist ( true , false , & components, & targets) ?;
710
+ distributable. install_from_dist ( true , false , & components, & targets, profile ) ?;
702
711
}
703
712
}
704
713
@@ -760,7 +769,7 @@ impl Cfg {
760
769
let channels = channels. map ( |( n, t) | {
761
770
let st = t. and_then ( |t| {
762
771
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 ) ;
764
773
if let Err ( ref e) = st {
765
774
( self . notify_handler ) ( Notification :: NonFatalError ( e) ) ;
766
775
}
@@ -815,7 +824,7 @@ impl Cfg {
815
824
let toolchain = self . get_toolchain ( toolchain, false ) ?;
816
825
if install_if_missing && !toolchain. exists ( ) {
817
826
let distributable = DistributableToolchain :: new ( & toolchain) ?;
818
- distributable. install_from_dist ( true , false , & [ ] , & [ ] ) ?;
827
+ distributable. install_from_dist ( true , false , & [ ] , & [ ] , None ) ?;
819
828
}
820
829
821
830
if let Some ( cmd) = self . maybe_do_cargo_fallback ( & toolchain, binary) ? {
@@ -911,6 +920,7 @@ mod tests {
911
920
channel: Some ( contents. into( ) ) ,
912
921
components: None ,
913
922
targets: None ,
923
+ profile: None ,
914
924
}
915
925
}
916
926
) ;
@@ -922,6 +932,7 @@ mod tests {
922
932
channel = "nightly-2020-07-10"
923
933
components = [ "rustfmt", "rustc-dev" ]
924
934
targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
935
+ profile = "default"
925
936
"# ;
926
937
927
938
let result = Cfg :: parse_override_file ( contents) ;
@@ -935,6 +946,7 @@ targets = [ "wasm32-unknown-unknown", "thumbv2-none-eabi" ]
935
946
"wasm32-unknown-unknown" . into( ) ,
936
947
"thumbv2-none-eabi" . into( )
937
948
] ) ,
949
+ profile: Some ( "default" . into( ) ) ,
938
950
}
939
951
}
940
952
) ;
@@ -954,6 +966,7 @@ channel = "nightly-2020-07-10"
954
966
channel: Some ( "nightly-2020-07-10" . into( ) ) ,
955
967
components: None ,
956
968
targets: None ,
969
+ profile: None ,
957
970
}
958
971
}
959
972
) ;
@@ -974,6 +987,7 @@ components = []
974
987
channel: Some ( "nightly-2020-07-10" . into( ) ) ,
975
988
components: Some ( vec![ ] ) ,
976
989
targets: None ,
990
+ profile: None ,
977
991
}
978
992
}
979
993
) ;
@@ -994,6 +1008,7 @@ targets = []
994
1008
channel: Some ( "nightly-2020-07-10" . into( ) ) ,
995
1009
components: None ,
996
1010
targets: Some ( vec![ ] ) ,
1011
+ profile: None ,
997
1012
}
998
1013
}
999
1014
) ;
@@ -1013,6 +1028,7 @@ components = [ "rustfmt" ]
1013
1028
channel: None ,
1014
1029
components: Some ( vec![ "rustfmt" . into( ) ] ) ,
1015
1030
targets: None ,
1031
+ profile: None ,
1016
1032
}
1017
1033
}
1018
1034
) ;
0 commit comments