use BTreeMap for region constraints
This commit is contained in:
parent
ee839b36ac
commit
501c558ffe
|
@ -30,6 +30,7 @@ use util::nodemap::{FxHashMap, FxHashSet};
|
|||
|
||||
use std::borrow::Cow;
|
||||
use std::collections::hash_map::Entry::Vacant;
|
||||
use std::collections::btree_map::BTreeMap;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
|
@ -124,7 +125,7 @@ pub fn maybe_print_constraints_for<'a, 'gcx, 'tcx>(
|
|||
struct ConstraintGraph<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
||||
graph_name: String,
|
||||
region_rels: &'a RegionRelations<'a, 'gcx, 'tcx>,
|
||||
map: &'a FxHashMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,
|
||||
map: &'a BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>,
|
||||
node_ids: FxHashMap<Node, usize>,
|
||||
}
|
||||
|
||||
|
@ -264,7 +265,7 @@ impl<'a, 'gcx, 'tcx> dot::GraphWalk<'a> for ConstraintGraph<'a, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
pub type ConstraintMap<'tcx> = FxHashMap<Constraint<'tcx>, SubregionOrigin<'tcx>>;
|
||||
pub type ConstraintMap<'tcx> = BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>;
|
||||
|
||||
fn dump_region_constraints_to<'a, 'gcx, 'tcx>(region_rels: &RegionRelations<'a, 'gcx, 'tcx>,
|
||||
map: &ConstraintMap<'tcx>,
|
||||
|
|
|
@ -28,6 +28,7 @@ use ty::{Region, RegionVid};
|
|||
use ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound, ReErased};
|
||||
use ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh};
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
|
@ -36,7 +37,7 @@ use std::u32;
|
|||
mod graphviz;
|
||||
|
||||
/// A constraint that influences the inference process.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
|
||||
pub enum Constraint<'tcx> {
|
||||
/// One region variable is subregion of another
|
||||
ConstrainVarSubVar(RegionVid, RegionVid),
|
||||
|
@ -186,7 +187,7 @@ pub struct RegionVarBindings<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
|
|||
/// Constraints of the form `A <= B` introduced by the region
|
||||
/// checker. Here at least one of `A` and `B` must be a region
|
||||
/// variable.
|
||||
constraints: RefCell<FxHashMap<Constraint<'tcx>, SubregionOrigin<'tcx>>>,
|
||||
constraints: RefCell<BTreeMap<Constraint<'tcx>, SubregionOrigin<'tcx>>>,
|
||||
|
||||
/// A "verify" is something that we need to verify after inference is
|
||||
/// done, but which does not directly affect inference in any way.
|
||||
|
@ -357,7 +358,7 @@ impl<'a, 'gcx, 'tcx> RegionVarBindings<'a, 'gcx, 'tcx> {
|
|||
tcx,
|
||||
var_origins: RefCell::new(Vec::new()),
|
||||
values: RefCell::new(None),
|
||||
constraints: RefCell::new(FxHashMap()),
|
||||
constraints: RefCell::new(BTreeMap::new()),
|
||||
verifys: RefCell::new(Vec::new()),
|
||||
givens: RefCell::new(FxHashSet()),
|
||||
lubs: RefCell::new(FxHashMap()),
|
||||
|
|
|
@ -760,7 +760,7 @@ impl<'a, 'gcx, 'tcx> ParamTy {
|
|||
/// is the outer fn.
|
||||
///
|
||||
/// [dbi]: http://en.wikipedia.org/wiki/De_Bruijn_index
|
||||
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug, Copy)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug, Copy, PartialOrd, Ord)]
|
||||
pub struct DebruijnIndex {
|
||||
/// We maintain the invariant that this is never 0. So 1 indicates
|
||||
/// the innermost binder. To ensure this, create with `DebruijnIndex::new`.
|
||||
|
@ -825,7 +825,7 @@ pub type Region<'tcx> = &'tcx RegionKind;
|
|||
///
|
||||
/// [1] http://smallcultfollowing.com/babysteps/blog/2013/10/29/intermingled-parameter-lists/
|
||||
/// [2] http://smallcultfollowing.com/babysteps/blog/2013/11/04/intermingled-parameter-lists/
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Copy, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, Copy, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
|
||||
pub enum RegionKind {
|
||||
// Region bound in a type or fn declaration which will be
|
||||
// substituted 'early' -- that is, at the same time when type
|
||||
|
@ -871,7 +871,7 @@ pub enum RegionKind {
|
|||
|
||||
impl<'tcx> serialize::UseSpecializedDecodable for Region<'tcx> {}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Debug, PartialOrd, Ord)]
|
||||
pub struct EarlyBoundRegion {
|
||||
pub def_id: DefId,
|
||||
pub index: u32,
|
||||
|
@ -893,12 +893,12 @@ pub struct FloatVid {
|
|||
pub index: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
|
||||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy, PartialOrd, Ord)]
|
||||
pub struct RegionVid {
|
||||
pub index: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, PartialOrd, Ord)]
|
||||
pub struct SkolemizedRegionVid {
|
||||
pub index: u32,
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {
|
|||
|
||||
#[cfg(krisskross)] // two instantiations, mixing and matching: BAD
|
||||
fn transmute<'a,'b>(x: Type<'a>, y: Type<'b>) -> (Type<'a>, Type<'b>) {
|
||||
let a = bar(foo, y);
|
||||
let b = bar(foo, x); //[krisskross]~ ERROR E0623
|
||||
let a = bar(foo, y); //[krisskross]~ ERROR E0623
|
||||
let b = bar(foo, x);
|
||||
(a, b) //[krisskross]~ ERROR E0623
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue