@@ -1014,27 +1014,33 @@ fn merge_config_profiles(
10141014 Some ( profiles) => profiles. get_all ( ) . clone ( ) ,
10151015 None => BTreeMap :: new ( ) ,
10161016 } ;
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) ;
10191020 // Merge config onto manifest profiles.
10201021 for ( name, profile) in & mut profiles {
10211022 if let Some ( config_profile) = get_config_profile ( name, config, features) ? {
10221023 profile. merge ( & config_profile) ;
10231024 }
10241025 if let Some ( inherits) = & profile. inherits {
1025- check_to_add. push ( * inherits) ;
1026+ check_to_add. insert ( * inherits) ;
10261027 }
10271028 }
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+ }
10281034 // Add config-only profiles.
10291035 // Need to iterate repeatedly to get all the inherits values.
1030- let mut current = Vec :: new ( ) ;
1036+ let mut current = HashSet :: new ( ) ;
10311037 while !check_to_add. is_empty ( ) {
10321038 std:: mem:: swap ( & mut current, & mut check_to_add) ;
1033- for name in current. drain ( .. ) {
1039+ for name in current. drain ( ) {
10341040 if !profiles. contains_key ( & name) {
10351041 if let Some ( config_profile) = get_config_profile ( & name, config, features) ? {
10361042 if let Some ( inherits) = & config_profile. inherits {
1037- check_to_add. push ( * inherits) ;
1043+ check_to_add. insert ( * inherits) ;
10381044 }
10391045 profiles. insert ( name, config_profile) ;
10401046 }
0 commit comments