@@ -1086,6 +1086,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1086
1086
this. add_module_candidates ( module, & mut suggestions, filter_fn, None ) ;
1087
1087
}
1088
1088
Scope :: MacroUsePrelude => {
1089
+ // The suggestions are deterministically sorted at the bottom of this function.
1090
+ #[ allow( rustc:: potential_query_instability) ]
1089
1091
suggestions. extend ( this. macro_use_prelude . iter ( ) . filter_map (
1090
1092
|( name, binding) | {
1091
1093
let res = binding. res ( ) ;
@@ -1104,6 +1106,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1104
1106
}
1105
1107
}
1106
1108
Scope :: ExternPrelude => {
1109
+ // The suggestions are deterministically sorted at the bottom of this function.
1110
+ #[ allow( rustc:: potential_query_instability) ]
1107
1111
suggestions. extend ( this. extern_prelude . iter ( ) . filter_map ( |( ident, _) | {
1108
1112
let res = Res :: Def ( DefKind :: Mod , CRATE_DEF_ID . to_def_id ( ) ) ;
1109
1113
filter_fn ( res) . then_some ( TypoSuggestion :: typo_from_ident ( * ident, res) )
@@ -1362,7 +1366,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1362
1366
) ;
1363
1367
1364
1368
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 {
1366
1375
if ident. span . from_expansion ( ) {
1367
1376
// Idents are adjusted to the root context before being
1368
1377
// resolved in the extern prelude, so reporting this to the
@@ -1467,7 +1476,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1467
1476
return ;
1468
1477
}
1469
1478
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) ) | {
1471
1484
if unused_ident. name == ident. name { Some ( ( def_id, unused_ident) ) } else { None }
1472
1485
} ) ;
1473
1486
@@ -1954,6 +1967,8 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1954
1967
ident : Symbol ,
1955
1968
current_module : Module < ' ra > ,
1956
1969
) -> Option < Symbol > {
1970
+ // The candidates are sorted just below.
1971
+ #[ allow( rustc:: potential_query_instability) ]
1957
1972
let mut candidates = self
1958
1973
. extern_prelude
1959
1974
. keys ( )
@@ -2342,6 +2357,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
2342
2357
// Sort extern crate names in *reverse* order to get
2343
2358
// 1) some consistent ordering for emitted diagnostics, and
2344
2359
// 2) `std` suggestions before `core` suggestions.
2360
+ #[ allow( rustc:: potential_query_instability) ]
2345
2361
let mut extern_crate_names =
2346
2362
self . extern_prelude . keys ( ) . map ( |ident| ident. name ) . collect :: < Vec < _ > > ( ) ;
2347
2363
extern_crate_names. sort_by ( |a, b| b. as_str ( ) . partial_cmp ( a. as_str ( ) ) . unwrap ( ) ) ;
@@ -2839,6 +2855,8 @@ fn show_candidates(
2839
2855
} else {
2840
2856
// Get the unique item kinds and if there's only one, we use the right kind name
2841
2857
// 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) ]
2842
2860
let mut kinds = accessible_path_strings
2843
2861
. iter ( )
2844
2862
. map ( |( _, descr, _, _, _) | * descr)
0 commit comments