@@ -1014,27 +1014,33 @@ fn merge_config_profiles(
1014
1014
Some ( profiles) => profiles. get_all ( ) . clone ( ) ,
1015
1015
None => BTreeMap :: new ( ) ,
1016
1016
} ;
1017
- // List of profile names to check if defined in config only.
1018
- let mut check_to_add = vec ! [ requested_profile] ;
1017
+ // Set of profile names to check if defined in config only.
1018
+ let mut check_to_add = HashSet :: new ( ) ;
1019
+ check_to_add. insert ( requested_profile) ;
1019
1020
// Merge config onto manifest profiles.
1020
1021
for ( name, profile) in & mut profiles {
1021
1022
if let Some ( config_profile) = get_config_profile ( name, config, features) ? {
1022
1023
profile. merge ( & config_profile) ;
1023
1024
}
1024
1025
if let Some ( inherits) = & profile. inherits {
1025
- check_to_add. push ( * inherits) ;
1026
+ check_to_add. insert ( * inherits) ;
1026
1027
}
1027
1028
}
1029
+ // Add the built-in profiles. This is important for things like `cargo
1030
+ // test` which implicitly use the "dev" profile for dependencies.
1031
+ for name in & [ "dev" , "release" , "test" , "bench" ] {
1032
+ check_to_add. insert ( InternedString :: new ( name) ) ;
1033
+ }
1028
1034
// Add config-only profiles.
1029
1035
// Need to iterate repeatedly to get all the inherits values.
1030
- let mut current = Vec :: new ( ) ;
1036
+ let mut current = HashSet :: new ( ) ;
1031
1037
while !check_to_add. is_empty ( ) {
1032
1038
std:: mem:: swap ( & mut current, & mut check_to_add) ;
1033
- for name in current. drain ( .. ) {
1039
+ for name in current. drain ( ) {
1034
1040
if !profiles. contains_key ( & name) {
1035
1041
if let Some ( config_profile) = get_config_profile ( & name, config, features) ? {
1036
1042
if let Some ( inherits) = & config_profile. inherits {
1037
- check_to_add. push ( * inherits) ;
1043
+ check_to_add. insert ( * inherits) ;
1038
1044
}
1039
1045
profiles. insert ( name, config_profile) ;
1040
1046
}
0 commit comments