diff --git a/compiler/rustc_lint/src/early/diagnostics/check_cfg.rs b/compiler/rustc_lint/src/early/diagnostics/check_cfg.rs index a211a1aaa6bdf..9fcabfa623d80 100644 --- a/compiler/rustc_lint/src/early/diagnostics/check_cfg.rs +++ b/compiler/rustc_lint/src/early/diagnostics/check_cfg.rs @@ -438,10 +438,10 @@ pub(super) fn unexpected_cfg_value( } } -/// Ordering of the output is not stable, use this only in diagnostic code. fn possible_well_known_names_for_cfg_value(sess: &Session, value: Symbol) -> Vec { #[allow(rustc::potential_query_instability)] - sess.psess + let mut names = sess + .psess .check_config .well_known_names .iter() @@ -454,5 +454,7 @@ fn possible_well_known_names_for_cfg_value(sess: &Session, value: Symbol) -> Vec .unwrap_or_default() }) .copied() - .collect() + .collect::>(); + names.sort_by(|a, b| a.as_str().cmp(b.as_str())); + names } diff --git a/tests/ui/cfg/suggest-alternative-name-on-target.rs b/tests/ui/cfg/suggest-alternative-name-on-target.rs index e3810dbbc9c36..297321a0e2fe0 100644 --- a/tests/ui/cfg/suggest-alternative-name-on-target.rs +++ b/tests/ui/cfg/suggest-alternative-name-on-target.rs @@ -32,8 +32,8 @@ struct D; #[cfg(target_abi = "windows")] //~^ ERROR unexpected `cfg` condition value: //~| NOTE see for more information about checking conditional configuration -help: `windows` is an expected value for `target_os` +help: `windows` is an expected value for `target_family` | LL - #[cfg(target_abi = "windows")] -LL + #[cfg(target_os = "windows")] +LL + #[cfg(target_family = "windows")] | -help: `windows` is an expected value for `target_family` +help: `windows` is an expected value for `target_os` | LL - #[cfg(target_abi = "windows")] -LL + #[cfg(target_family = "windows")] +LL + #[cfg(target_os = "windows")] | error: aborting due to 5 previous errors