From b84f294c4672018e237e8196eef59bb668b805f2 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 20 Dec 2013 13:24:14 -0800 Subject: [PATCH] librustc: De-`@mut` `glbs` and `lubs` in `RegionVarBindings` --- .../typeck/infer/region_inference/mod.rs | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 140df98763e..7808733d9b4 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -90,8 +90,8 @@ pub struct RegionVarBindings { tcx: ty::ctxt, var_origins: ~[RegionVariableOrigin], constraints: RefCell>, - lubs: CombineMap, - glbs: CombineMap, + lubs: RefCell, + glbs: RefCell, skolemization_count: Cell, bound_count: Cell, @@ -116,8 +116,8 @@ pub fn RegionVarBindings(tcx: ty::ctxt) -> RegionVarBindings { var_origins: ~[], values: None, constraints: RefCell::new(HashMap::new()), - lubs: HashMap::new(), - glbs: HashMap::new(), + lubs: RefCell::new(HashMap::new()), + glbs: RefCell::new(HashMap::new()), skolemization_count: Cell::new(0), bound_count: Cell::new(0), undo_log: ~[] @@ -162,10 +162,12 @@ impl RegionVarBindings { constraints.get().remove(constraint); } AddCombination(Glb, ref regions) => { - self.glbs.remove(regions); + let mut glbs = self.glbs.borrow_mut(); + glbs.get().remove(regions); } AddCombination(Lub, ref regions) => { - self.lubs.remove(regions); + let mut lubs = self.lubs.borrow_mut(); + lubs.get().remove(regions); } } } @@ -345,10 +347,8 @@ impl RegionVarBindings { } } - fn combine_map<'a>(&'a mut self, - t: CombineMapType) - -> &'a mut CombineMap - { + fn combine_map<'a>(&'a mut self, t: CombineMapType) + -> &'a mut RefCell { match t { Glb => &mut self.glbs, Lub => &mut self.lubs, @@ -365,14 +365,20 @@ impl RegionVarBindings { new_r: Region|) -> Region { let vars = TwoRegions { a: a, b: b }; - match self.combine_map(t).find(&vars) { - Some(&c) => { - return ReInfer(ReVar(c)); + { + let map = self.combine_map(t).borrow(); + match map.get().find(&vars) { + Some(&c) => { + return ReInfer(ReVar(c)); + } + None => {} } - None => {} } let c = self.new_region_var(infer::MiscVariable(origin.span())); - self.combine_map(t).insert(vars, c); + { + let mut map = self.combine_map(t).borrow_mut(); + map.get().insert(vars, c); + } if self.in_snapshot() { self.undo_log.push(AddCombination(t, vars)); }