@@ -999,27 +999,33 @@ fn merge_config_profiles(
999999 Some ( profiles) => profiles. get_all ( ) . clone ( ) ,
10001000 None => BTreeMap :: new ( ) ,
10011001 } ;
1002- // List of profile names to check if defined in config only.
1003- let mut check_to_add = vec ! [ requested_profile] ;
1002+ // Set of profile names to check if defined in config only.
1003+ let mut check_to_add = HashSet :: new ( ) ;
1004+ check_to_add. insert ( requested_profile) ;
10041005 // Merge config onto manifest profiles.
10051006 for ( name, profile) in & mut profiles {
10061007 if let Some ( config_profile) = get_config_profile ( name, config, features) ? {
10071008 profile. merge ( & config_profile) ;
10081009 }
10091010 if let Some ( inherits) = & profile. inherits {
1010- check_to_add. push ( * inherits) ;
1011+ check_to_add. insert ( * inherits) ;
10111012 }
10121013 }
1014+ // Add the built-in profiles. This is important for things like `cargo
1015+ // test` which implicitly use the "dev" profile for dependencies.
1016+ for name in & [ "dev" , "release" , "test" , "bench" ] {
1017+ check_to_add. insert ( InternedString :: new ( name) ) ;
1018+ }
10131019 // Add config-only profiles.
10141020 // Need to iterate repeatedly to get all the inherits values.
1015- let mut current = Vec :: new ( ) ;
1021+ let mut current = HashSet :: new ( ) ;
10161022 while !check_to_add. is_empty ( ) {
10171023 std:: mem:: swap ( & mut current, & mut check_to_add) ;
1018- for name in current. drain ( .. ) {
1024+ for name in current. drain ( ) {
10191025 if !profiles. contains_key ( & name) {
10201026 if let Some ( config_profile) = get_config_profile ( & name, config, features) ? {
10211027 if let Some ( inherits) = & config_profile. inherits {
1022- check_to_add. push ( * inherits) ;
1028+ check_to_add. insert ( * inherits) ;
10231029 }
10241030 profiles. insert ( name, config_profile) ;
10251031 }
0 commit comments