Skip to content

Commit 9877fa0

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 ff8cd2e commit 9877fa0

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_constraints::{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};
@@ -246,7 +247,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
246247
snapshot: &CombinedSnapshot,
247248
debruijn: ty::DebruijnIndex,
248249
new_vars: &[ty::RegionVid],
249-
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
250+
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
250251
r0: ty::Region<'tcx>)
251252
-> ty::Region<'tcx> {
252253
// Regions that pre-dated the LUB computation stay as they are.
@@ -342,7 +343,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
342343
snapshot: &CombinedSnapshot,
343344
debruijn: ty::DebruijnIndex,
344345
new_vars: &[ty::RegionVid],
345-
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
346+
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
346347
a_vars: &[ty::RegionVid],
347348
b_vars: &[ty::RegionVid],
348349
r0: ty::Region<'tcx>)
@@ -411,7 +412,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
411412

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

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

src/librustc/infer/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use ty::relate::RelateResult;
3131
use traits::{self, ObligationCause, PredicateObligations, Reveal};
3232
use rustc_data_structures::unify::{self, UnificationTable};
3333
use std::cell::{Cell, RefCell, Ref, RefMut};
34+
use std::collections::BTreeMap;
3435
use std::fmt;
3536
use syntax::ast;
3637
use errors::DiagnosticBuilder;
@@ -184,7 +185,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
184185

185186
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
186187
/// region that each late-bound region was replaced with.
187-
pub type SkolemizationMap<'tcx> = FxHashMap<ty::BoundRegion, ty::Region<'tcx>>;
188+
pub type SkolemizationMap<'tcx> = BTreeMap<ty::BoundRegion, ty::Region<'tcx>>;
188189

189190
/// See `error_reporting` module for more details
190191
#[derive(Clone, Debug)]
@@ -1384,7 +1385,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
13841385
span: Span,
13851386
lbrct: LateBoundRegionConversionTime,
13861387
value: &ty::Binder<T>)
1387-
-> (T, FxHashMap<ty::BoundRegion, ty::Region<'tcx>>)
1388+
-> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
13881389
where T : TypeFoldable<'tcx>
13891390
{
13901391
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)