@@ -1086,6 +1086,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
10861086 this. add_module_candidates ( module, & mut suggestions, filter_fn, None ) ;
10871087 }
10881088 Scope :: MacroUsePrelude => {
1089+ // The suggestions are deterministically sorted at the bottom of this function.
1090+ #[ allow( rustc:: potential_query_instability) ]
10891091 suggestions. extend ( this. macro_use_prelude . iter ( ) . filter_map (
10901092 |( name, binding) | {
10911093 let res = binding. res ( ) ;
@@ -1104,6 +1106,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
11041106 }
11051107 }
11061108 Scope :: ExternPrelude => {
1109+ // The suggestions are deterministically sorted at the bottom of this function.
1110+ #[ allow( rustc:: potential_query_instability) ]
11071111 suggestions. extend ( this. extern_prelude . iter ( ) . filter_map ( |( ident, _) | {
11081112 let res = Res :: Def ( DefKind :: Mod , CRATE_DEF_ID . to_def_id ( ) ) ;
11091113 filter_fn ( res) . then_some ( TypoSuggestion :: typo_from_ident ( * ident, res) )
@@ -1362,7 +1366,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
13621366 ) ;
13631367
13641368 if lookup_ident. span . at_least_rust_2018 ( ) {
1365- for ident in self . extern_prelude . clone ( ) . into_keys ( ) {
1369+ // `idents` is sorted before usage so ordering is not important here.
1370+ #[ allow( rustc:: potential_query_instability) ]
1371+ let mut idents: Vec < _ > = self . extern_prelude . clone ( ) . into_keys ( ) . collect ( ) ;
1372+ idents. sort_by_key ( |ident| ident. span ) ;
1373+
1374+ for ident in idents {
13661375 if ident. span . from_expansion ( ) {
13671376 // Idents are adjusted to the root context before being
13681377 // resolved in the extern prelude, so reporting this to the
@@ -1467,7 +1476,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14671476 return ;
14681477 }
14691478
1470- let unused_macro = self . unused_macros . iter ( ) . find_map ( |( def_id, ( _, unused_ident) ) | {
1479+ // Make ordering consistent before iteration
1480+ #[ allow( rustc:: potential_query_instability) ]
1481+ let mut unused_macros: Vec < _ > = self . unused_macros . iter ( ) . collect ( ) ;
1482+ unused_macros. sort_by_key ( |& ( _, ( key, _) ) | key) ;
1483+ let unused_macro = unused_macros. iter ( ) . find_map ( |( def_id, ( _, unused_ident) ) | {
14711484 if unused_ident. name == ident. name { Some ( ( def_id, unused_ident) ) } else { None }
14721485 } ) ;
14731486
@@ -1954,6 +1967,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
19541967 ident : Symbol ,
19551968 current_module : Module < ' ra > ,
19561969 ) -> Option < Symbol > {
1970+ // The candidates are sorted just below.
1971+ #[ allow( rustc:: potential_query_instability) ]
19571972 let mut candidates = self
19581973 . extern_prelude
19591974 . keys ( )
@@ -2342,6 +2357,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
23422357 // Sort extern crate names in *reverse* order to get
23432358 // 1) some consistent ordering for emitted diagnostics, and
23442359 // 2) `std` suggestions before `core` suggestions.
2360+ #[ allow( rustc:: potential_query_instability) ]
23452361 let mut extern_crate_names =
23462362 self . extern_prelude . keys ( ) . map ( |ident| ident. name ) . collect :: < Vec < _ > > ( ) ;
23472363 extern_crate_names. sort_by ( |a, b| b. as_str ( ) . partial_cmp ( a. as_str ( ) ) . unwrap ( ) ) ;
@@ -2839,6 +2855,8 @@ fn show_candidates(
28392855 } else {
28402856 // Get the unique item kinds and if there's only one, we use the right kind name
28412857 // instead of the more generic "items".
2858+ // Ordering is not important if there's only one element in the set.
2859+ #[ allow( rustc:: potential_query_instability) ]
28422860 let mut kinds = accessible_path_strings
28432861 . iter ( )
28442862 . map ( |( _, descr, _, _, _) | * descr)
0 commit comments