Skip to content

Commit bb0e756

Browse files
committed
use a BTreeMap instead of an FxHasMap for the skol regions
The ordering can affect error msg, and this map is not a high performance pathway.
1 parent 0bbbfaf commit bb0e756

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/librustc/infer/higher_ranked/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use super::{CombinedSnapshot,
1919
use super::combine::CombineFields;
2020
use super::region_inference::{TaintDirections};
2121

22+
use std::collections::BTreeMap;
2223
use ty::{self, TyCtxt, Binder, TypeFoldable};
2324
use ty::error::TypeError;
2425
use ty::relate::{Relate, RelateResult, TypeRelation};
@@ -245,7 +246,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
245246
snapshot: &CombinedSnapshot,
246247
debruijn: ty::DebruijnIndex,
247248
new_vars: &[ty::RegionVid],
248-
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
249+
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
249250
r0: ty::Region<'tcx>)
250251
-> ty::Region<'tcx> {
251252
// Regions that pre-dated the LUB computation stay as they are.
@@ -341,7 +342,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
341342
snapshot: &CombinedSnapshot,
342343
debruijn: ty::DebruijnIndex,
343344
new_vars: &[ty::RegionVid],
344-
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
345+
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
345346
a_vars: &[ty::RegionVid],
346347
b_vars: &[ty::RegionVid],
347348
r0: ty::Region<'tcx>)
@@ -410,7 +411,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
410411

411412
fn rev_lookup<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
412413
span: Span,
413-
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
414+
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
414415
r: ty::Region<'tcx>) -> ty::Region<'tcx>
415416
{
416417
for (a_br, a_r) in a_map {
@@ -433,7 +434,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
433434
}
434435

435436
fn var_ids<'a, 'gcx, 'tcx>(fields: &CombineFields<'a, 'gcx, 'tcx>,
436-
map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>)
437+
map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
437438
-> Vec<ty::RegionVid> {
438439
map.iter()
439440
.map(|(_, &r)| match *r {

src/librustc/infer/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use ty::relate::RelateResult;
3232
use traits::{self, ObligationCause, PredicateObligations, Reveal};
3333
use rustc_data_structures::unify::{self, UnificationTable};
3434
use std::cell::{Cell, RefCell, Ref};
35+
use std::collections::BTreeMap;
3536
use std::fmt;
3637
use syntax::ast;
3738
use errors::DiagnosticBuilder;
@@ -139,7 +140,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
139140

140141
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
141142
/// region that each late-bound region was replaced with.
142-
pub type SkolemizationMap<'tcx> = FxHashMap<ty::BoundRegion, ty::Region<'tcx>>;
143+
pub type SkolemizationMap<'tcx> = BTreeMap<ty::BoundRegion, ty::Region<'tcx>>;
143144

144145
/// See `error_reporting` module for more details
145146
#[derive(Clone, Debug)]
@@ -1260,7 +1261,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
12601261
span: Span,
12611262
lbrct: LateBoundRegionConversionTime,
12621263
value: &ty::Binder<T>)
1263-
-> (T, FxHashMap<ty::BoundRegion, ty::Region<'tcx>>)
1264+
-> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
12641265
where T : TypeFoldable<'tcx>
12651266
{
12661267
self.tcx.replace_late_bound_regions(

src/librustc/ty/fold.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ use middle::const_val::ConstVal;
4343
use ty::{self, Binder, Ty, TyCtxt, TypeFlags};
4444

4545
use std::fmt;
46-
use util::nodemap::{FxHashMap, FxHashSet};
46+
use std::collections::BTreeMap;
47+
use util::nodemap::FxHashSet;
4748

4849
/// The TypeFoldable trait is implemented for every type that can be folded.
4950
/// Basically, every type that has a corresponding method in TypeFolder.
@@ -324,14 +325,14 @@ struct RegionReplacer<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
324325
tcx: TyCtxt<'a, 'gcx, 'tcx>,
325326
current_depth: u32,
326327
fld_r: &'a mut (FnMut(ty::BoundRegion) -> ty::Region<'tcx> + 'a),
327-
map: FxHashMap<ty::BoundRegion, ty::Region<'tcx>>
328+
map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>
328329
}
329330

330331
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
331332
pub fn replace_late_bound_regions<T,F>(self,
332333
value: &Binder<T>,
333334
mut f: F)
334-
-> (T, FxHashMap<ty::BoundRegion, ty::Region<'tcx>>)
335+
-> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
335336
where F : FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
336337
T : TypeFoldable<'tcx>,
337338
{
@@ -438,7 +439,7 @@ impl<'a, 'gcx, 'tcx> RegionReplacer<'a, 'gcx, 'tcx> {
438439
tcx,
439440
current_depth: 1,
440441
fld_r,
441-
map: FxHashMap()
442+
map: BTreeMap::default()
442443
}
443444
}
444445
}

0 commit comments

Comments
 (0)