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.
This commit is contained in:
parent
ff8cd2e428
commit
9877fa048d
3 changed files with 13 additions and 10 deletions
|
|
@ -19,6 +19,7 @@ use super::{CombinedSnapshot,
|
|||
use super::combine::CombineFields;
|
||||
use super::region_constraints::{TaintDirections};
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use ty::{self, TyCtxt, Binder, TypeFoldable};
|
||||
use ty::error::TypeError;
|
||||
use ty::relate::{Relate, RelateResult, TypeRelation};
|
||||
|
|
@ -246,7 +247,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
|
|||
snapshot: &CombinedSnapshot,
|
||||
debruijn: ty::DebruijnIndex,
|
||||
new_vars: &[ty::RegionVid],
|
||||
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
|
||||
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
|
||||
r0: ty::Region<'tcx>)
|
||||
-> ty::Region<'tcx> {
|
||||
// Regions that pre-dated the LUB computation stay as they are.
|
||||
|
|
@ -342,7 +343,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
|
|||
snapshot: &CombinedSnapshot,
|
||||
debruijn: ty::DebruijnIndex,
|
||||
new_vars: &[ty::RegionVid],
|
||||
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
|
||||
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
|
||||
a_vars: &[ty::RegionVid],
|
||||
b_vars: &[ty::RegionVid],
|
||||
r0: ty::Region<'tcx>)
|
||||
|
|
@ -411,7 +412,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
|
|||
|
||||
fn rev_lookup<'a, 'gcx, 'tcx>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
|
||||
span: Span,
|
||||
a_map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>,
|
||||
a_map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>,
|
||||
r: ty::Region<'tcx>) -> ty::Region<'tcx>
|
||||
{
|
||||
for (a_br, a_r) in a_map {
|
||||
|
|
@ -434,7 +435,7 @@ impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
fn var_ids<'a, 'gcx, 'tcx>(fields: &CombineFields<'a, 'gcx, 'tcx>,
|
||||
map: &FxHashMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||
map: &BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||
-> Vec<ty::RegionVid> {
|
||||
map.iter()
|
||||
.map(|(_, &r)| match *r {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ use ty::relate::RelateResult;
|
|||
use traits::{self, ObligationCause, PredicateObligations, Reveal};
|
||||
use rustc_data_structures::unify::{self, UnificationTable};
|
||||
use std::cell::{Cell, RefCell, Ref, RefMut};
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
use errors::DiagnosticBuilder;
|
||||
|
|
@ -184,7 +185,7 @@ pub struct InferCtxt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
|||
|
||||
/// A map returned by `skolemize_late_bound_regions()` indicating the skolemized
|
||||
/// region that each late-bound region was replaced with.
|
||||
pub type SkolemizationMap<'tcx> = FxHashMap<ty::BoundRegion, ty::Region<'tcx>>;
|
||||
pub type SkolemizationMap<'tcx> = BTreeMap<ty::BoundRegion, ty::Region<'tcx>>;
|
||||
|
||||
/// See `error_reporting` module for more details
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -1384,7 +1385,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
span: Span,
|
||||
lbrct: LateBoundRegionConversionTime,
|
||||
value: &ty::Binder<T>)
|
||||
-> (T, FxHashMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||
-> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||
where T : TypeFoldable<'tcx>
|
||||
{
|
||||
self.tcx.replace_late_bound_regions(
|
||||
|
|
|
|||
|
|
@ -43,7 +43,8 @@ use middle::const_val::ConstVal;
|
|||
use ty::{self, Binder, Ty, TyCtxt, TypeFlags};
|
||||
|
||||
use std::fmt;
|
||||
use util::nodemap::{FxHashMap, FxHashSet};
|
||||
use std::collections::BTreeMap;
|
||||
use util::nodemap::FxHashSet;
|
||||
|
||||
/// The TypeFoldable trait is implemented for every type that can be folded.
|
||||
/// Basically, every type that has a corresponding method in TypeFolder.
|
||||
|
|
@ -324,14 +325,14 @@ struct RegionReplacer<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
|||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
current_depth: u32,
|
||||
fld_r: &'a mut (FnMut(ty::BoundRegion) -> ty::Region<'tcx> + 'a),
|
||||
map: FxHashMap<ty::BoundRegion, ty::Region<'tcx>>
|
||||
map: BTreeMap<ty::BoundRegion, ty::Region<'tcx>>
|
||||
}
|
||||
|
||||
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
||||
pub fn replace_late_bound_regions<T,F>(self,
|
||||
value: &Binder<T>,
|
||||
mut f: F)
|
||||
-> (T, FxHashMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||
-> (T, BTreeMap<ty::BoundRegion, ty::Region<'tcx>>)
|
||||
where F : FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
|
||||
T : TypeFoldable<'tcx>,
|
||||
{
|
||||
|
|
@ -438,7 +439,7 @@ impl<'a, 'gcx, 'tcx> RegionReplacer<'a, 'gcx, 'tcx> {
|
|||
tcx,
|
||||
current_depth: 1,
|
||||
fld_r,
|
||||
map: FxHashMap()
|
||||
map: BTreeMap::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue