use ty::{self, Ty, TyCtxt, TypeFoldable};
use ty::fold::TypeFolder;
-use std::collections::hash_map::{self, Entry};
+use util::nodemap::FnvHashMap;
+use std::collections::hash_map::Entry;
use super::InferCtxt;
use super::unify_key::ToType;
pub struct TypeFreshener<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
infcx: &'a InferCtxt<'a, 'gcx, 'tcx>,
freshen_count: u32,
- freshen_map: hash_map::HashMap<ty::InferTy, Ty<'tcx>>,
+ freshen_map: FnvHashMap<ty::InferTy, Ty<'tcx>>,
}
impl<'a, 'gcx, 'tcx> TypeFreshener<'a, 'gcx, 'tcx> {
TypeFreshener {
infcx: infcx,
freshen_count: 0,
- freshen_map: hash_map::HashMap::new(),
+ freshen_map: FnvHashMap(),
}
}
self.infcx.tcx
}
- fn fold_region(&mut self, r: ty::Region) -> ty::Region {
- match r {
+ fn fold_region(&mut self, r: &'tcx ty::Region) -> &'tcx ty::Region {
+ match *r {
ty::ReEarlyBound(..) |
ty::ReLateBound(..) => {
// leave bound regions alone
ty::ReEmpty |
ty::ReErased => {
// replace all free regions with 'erased
- ty::ReErased
+ self.tcx().mk_region(ty::ReErased)
}
}
}