From 06805209e4f03f32ec0e06b156bb76fbf8f7a93e Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 18 Dec 2013 17:49:17 -0800 Subject: [PATCH] librustc: De-`@mut` `lltypes`. --- src/librustc/middle/trans/context.rs | 4 ++-- src/librustc/middle/trans/type_of.rs | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs index 4474890cc759..eaf94568d934 100644 --- a/src/librustc/middle/trans/context.rs +++ b/src/librustc/middle/trans/context.rs @@ -92,7 +92,7 @@ pub struct CrateContext { impl_method_cache: RefCell>, module_data: RefCell>, - lltypes: HashMap, + lltypes: RefCell>, llsizingtypes: HashMap, adt_reprs: HashMap, symbol_hasher: Sha256, @@ -203,7 +203,7 @@ impl CrateContext { extern_const_values: RefCell::new(HashMap::new()), impl_method_cache: RefCell::new(HashMap::new()), module_data: RefCell::new(HashMap::new()), - lltypes: HashMap::new(), + lltypes: RefCell::new(HashMap::new()), llsizingtypes: HashMap::new(), adt_reprs: HashMap::new(), symbol_hasher: symbol_hasher, diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs index 17620a81e51a..7f3cee7c4024 100644 --- a/src/librustc/middle/trans/type_of.rs +++ b/src/librustc/middle/trans/type_of.rs @@ -173,11 +173,12 @@ pub fn sizing_type_of(cx: &mut CrateContext, t: ty::t) -> Type { // NB: If you update this, be sure to update `sizing_type_of()` as well. pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type { // Check the cache. - match cx.lltypes.find(&t) { - Some(&llty) => { - return llty; + { + let lltypes = cx.lltypes.borrow(); + match lltypes.get().find(&t) { + Some(&llty) => return llty, + None => () } - None => () } debug!("type_of {} {:?}", t.repr(cx.tcx), t); @@ -197,7 +198,8 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type { t_norm.repr(cx.tcx), t_norm, cx.tn.type_to_str(llty)); - cx.lltypes.insert(t, llty); + let mut lltypes = cx.lltypes.borrow_mut(); + lltypes.get().insert(t, llty); return llty; } @@ -316,7 +318,10 @@ pub fn type_of(cx: &mut CrateContext, t: ty::t) -> Type { t.repr(cx.tcx), t, cx.tn.type_to_str(llty)); - cx.lltypes.insert(t, llty); + { + let mut lltypes = cx.lltypes.borrow_mut(); + lltypes.get().insert(t, llty); + } // If this was an enum or struct, fill in the type now. match ty::get(t).sty {