File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
rustc_data_structures/src Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ fn do_mir_borrowck<'a, 'tcx>(
236236 // Compute non-lexical lifetimes.
237237 let nll:: NllOutput {
238238 regioncx,
239- opaque_type_values,
239+ mut opaque_type_values,
240240 polonius_input,
241241 polonius_output,
242242 opt_closure_req,
@@ -437,6 +437,12 @@ fn do_mir_borrowck<'a, 'tcx>(
437437
438438 let tainted_by_errors = mbcx. emit_errors ( ) ;
439439
440+ // Since `BorrowCheckResult` is a query result, let's make sure that its `concrete_opaque_types`
441+ // field is in deterministic order.
442+ // Note, that this is not the best solution. It would be better to use a collection type
443+ // that does not expose its internal order at all once that's available (see #63713).
444+ opaque_type_values. sort_deterministically ( & infcx. tcx . create_stable_hashing_context ( ) ) ;
445+
440446 let result = BorrowCheckResult {
441447 concrete_opaque_types : opaque_type_values,
442448 closure_requirements : opt_closure_req,
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use std::iter::FromIterator;
44use std:: slice:: Iter ;
55use std:: vec:: IntoIter ;
66
7- use crate :: stable_hasher:: { HashStable , StableHasher } ;
7+ use crate :: stable_hasher:: { HashStable , StableHasher , ToStableHashKey } ;
88
99/// A map type implemented as a vector of pairs `K` (key) and `V` (value).
1010/// It currently provides a subset of all the map operations, the rest could be added as needed.
@@ -190,5 +190,14 @@ where
190190 }
191191}
192192
193+ impl < K , V > VecMap < K , V > {
194+ pub fn sort_deterministically < HCX > ( & mut self , hcx : & HCX )
195+ where
196+ K : ToStableHashKey < HCX > ,
197+ {
198+ self . 0 . sort_by_cached_key ( |( k, _) | k. to_stable_hash_key ( hcx) ) ;
199+ }
200+ }
201+
193202#[ cfg( test) ]
194203mod tests;
You can’t perform that action at this time.
0 commit comments