Auto merge of #8013 - ehuss:beta-config-profile-fix, r=alexcrichton · rust-lang/cargo@3532cf7 (original) (raw)
`@@ -999,27 +999,33 @@ fn merge_config_profiles(
`
999
999
`Some(profiles) => profiles.get_all().clone(),
`
1000
1000
`None => BTreeMap::new(),
`
1001
1001
`};
`
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);
`
1004
1005
`// Merge config onto manifest profiles.
`
1005
1006
`for (name, profile) in &mut profiles {
`
1006
1007
`if let Some(config_profile) = get_config_profile(name, config, features)? {
`
1007
1008
` profile.merge(&config_profile);
`
1008
1009
`}
`
1009
1010
`if let Some(inherits) = &profile.inherits {
`
1010
``
`-
check_to_add.push(*inherits);
`
``
1011
`+
check_to_add.insert(*inherits);
`
1011
1012
`}
`
1012
1013
`}
`
``
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
`+
}
`
1013
1019
`// Add config-only profiles.
`
1014
1020
`// Need to iterate repeatedly to get all the inherits values.
`
1015
``
`-
let mut current = Vec::new();
`
``
1021
`+
let mut current = HashSet::new();
`
1016
1022
`while !check_to_add.is_empty() {
`
1017
1023
` std::mem::swap(&mut current, &mut check_to_add);
`
1018
``
`-
for name in current.drain(..) {
`
``
1024
`+
for name in current.drain() {
`
1019
1025
`if !profiles.contains_key(&name) {
`
1020
1026
`if let Some(config_profile) = get_config_profile(&name, config, features)? {
`
1021
1027
`if let Some(inherits) = &config_profile.inherits {
`
1022
``
`-
check_to_add.push(*inherits);
`
``
1028
`+
check_to_add.insert(*inherits);
`
1023
1029
`}
`
1024
1030
` profiles.insert(name, config_profile);
`
1025
1031
`}
`