Skip to content

Commit 5a60f0a

Browse files
committed
Sort mir_keys to ensure consistent diagnostic order.
1 parent d88420a commit 5a60f0a

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+18-5
Original file line numberDiff line numberDiff line change
@@ -1185,11 +1185,24 @@ impl EncodeContext<'a, 'tcx> {
11851185
if self.is_proc_macro {
11861186
return;
11871187
}
1188-
for &def_id in self.tcx.mir_keys(LOCAL_CRATE).iter() {
1189-
let (encode_const, encode_opt) = should_encode_mir(self.tcx, def_id);
1190-
if !encode_const && !encode_opt {
1191-
continue;
1192-
}
1188+
1189+
let mut keys_and_jobs = self
1190+
.tcx
1191+
.mir_keys(LOCAL_CRATE)
1192+
.iter()
1193+
.filter_map(|&def_id| {
1194+
let (encode_const, encode_opt) = should_encode_mir(self.tcx, def_id);
1195+
if encode_const || encode_opt {
1196+
Some((def_id, encode_const, encode_opt))
1197+
} else {
1198+
None
1199+
}
1200+
})
1201+
.collect::<Vec<_>>();
1202+
// Sort everything to ensure a stable order for diagnotics.
1203+
keys_and_jobs.sort_by_key(|&(def_id, _, _)| def_id);
1204+
for (def_id, encode_const, encode_opt) in keys_and_jobs.into_iter() {
1205+
debug_assert!(encode_const || encode_opt);
11931206

11941207
debug!("EntryBuilder::encode_mir({:?})", def_id);
11951208
if encode_opt {

0 commit comments

Comments
 (0)