Skip to content

Commit 0944d8c

Browse files
committed
Sort idents before usage instead of suggestions to have a stable order
As requested by @petrochenkov
1 parent 2ff01e8 commit 0944d8c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

compiler/rustc_resolve/src/diagnostics.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1366,9 +1366,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
13661366
);
13671367

13681368
if lookup_ident.span.at_least_rust_2018() {
1369-
// Extended suggestions will be sorted at the end of this function.
1369+
// `idents` is sorted before usage so ordering is not important here.
13701370
#[allow(rustc::potential_query_instability)]
1371-
for ident in self.extern_prelude.clone().into_keys() {
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 {
13721375
if ident.span.from_expansion() {
13731376
// Idents are adjusted to the root context before being
13741377
// resolved in the extern prelude, so reporting this to the
@@ -1422,8 +1425,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14221425
}
14231426
}
14241427

1425-
// Make sure error reporting is deterministic.
1426-
suggestions.sort_by_key(|suggestion| suggestion.did.unwrap().index);
14271428
suggestions
14281429
}
14291430

0 commit comments

Comments
 (0)