diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2020-12-27 23:46:41 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-01-24 12:45:26 +0100 |
| commit | 5a60f0a86f2065742a1a70cd38fdc63fc1b95c61 (patch) | |
| tree | 37f64848f09abac0442d1b4653d650e46e1a7383 | |
| parent | d88420a52a9d1860b47245fdda374162d1c0972c (diff) | |
| download | rust-5a60f0a86f2065742a1a70cd38fdc63fc1b95c61.tar.gz rust-5a60f0a86f2065742a1a70cd38fdc63fc1b95c61.zip | |
Sort mir_keys to ensure consistent diagnostic order.
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index 48524e81f3e..8b9f10bf284 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -1185,11 +1185,24 @@ impl EncodeContext<'a, 'tcx> { if self.is_proc_macro { return; } - for &def_id in self.tcx.mir_keys(LOCAL_CRATE).iter() { - let (encode_const, encode_opt) = should_encode_mir(self.tcx, def_id); - if !encode_const && !encode_opt { - continue; - } + + let mut keys_and_jobs = self + .tcx + .mir_keys(LOCAL_CRATE) + .iter() + .filter_map(|&def_id| { + let (encode_const, encode_opt) = should_encode_mir(self.tcx, def_id); + if encode_const || encode_opt { + Some((def_id, encode_const, encode_opt)) + } else { + None + } + }) + .collect::<Vec<_>>(); + // Sort everything to ensure a stable order for diagnotics. + keys_and_jobs.sort_by_key(|&(def_id, _, _)| def_id); + for (def_id, encode_const, encode_opt) in keys_and_jobs.into_iter() { + debug_assert!(encode_const || encode_opt); debug!("EntryBuilder::encode_mir({:?})", def_id); if encode_opt { |
