@@ -309,7 +309,7 @@ struct ctxt_ {
309
309
rcache : creader_cache ,
310
310
short_names_cache : RefCell < HashMap < t , @str > > ,
311
311
needs_unwind_cleanup_cache : RefCell < HashMap < t , bool > > ,
312
- tc_cache : @ mut HashMap < uint , TypeContents > ,
312
+ tc_cache : RefCell < HashMap < uint , TypeContents > > ,
313
313
ast_ty_to_ty_cache : @mut HashMap < NodeId , ast_ty_to_ty_cache_entry > ,
314
314
enum_var_cache : @mut HashMap < DefId , @~[ @VariantInfo ] > ,
315
315
ty_param_defs : @mut HashMap < ast:: NodeId , TypeParameterDef > ,
@@ -995,7 +995,7 @@ pub fn mk_ctxt(s: session::Session,
995
995
rcache : mk_rcache ( ) ,
996
996
short_names_cache : RefCell :: new ( HashMap :: new ( ) ) ,
997
997
needs_unwind_cleanup_cache : RefCell :: new ( HashMap :: new ( ) ) ,
998
- tc_cache : @ mut HashMap :: new ( ) ,
998
+ tc_cache : RefCell :: new ( HashMap :: new ( ) ) ,
999
999
ast_ty_to_ty_cache : @mut HashMap :: new ( ) ,
1000
1000
enum_var_cache : @mut HashMap :: new ( ) ,
1001
1001
methods : RefCell :: new ( HashMap :: new ( ) ) ,
@@ -1970,14 +1970,20 @@ pub fn type_is_freezable(cx: ctxt, t: ty::t) -> bool {
1970
1970
1971
1971
pub fn type_contents ( cx : ctxt , ty : t ) -> TypeContents {
1972
1972
let ty_id = type_id ( ty) ;
1973
- match cx. tc_cache . find ( & ty_id) {
1974
- Some ( tc) => { return * tc; }
1975
- None => { }
1973
+
1974
+ {
1975
+ let tc_cache = cx. tc_cache . borrow ( ) ;
1976
+ match tc_cache. get ( ) . find ( & ty_id) {
1977
+ Some ( tc) => { return * tc; }
1978
+ None => { }
1979
+ }
1976
1980
}
1977
1981
1978
1982
let mut cache = HashMap :: new ( ) ;
1979
1983
let result = tc_ty ( cx, ty, & mut cache) ;
1980
- cx. tc_cache . insert ( ty_id, result) ;
1984
+
1985
+ let mut tc_cache = cx. tc_cache . borrow_mut ( ) ;
1986
+ tc_cache. get ( ) . insert ( ty_id, result) ;
1981
1987
return result;
1982
1988
1983
1989
fn tc_ty ( cx : ctxt ,
@@ -2010,9 +2016,12 @@ pub fn type_contents(cx: ctxt, ty: t) -> TypeContents {
2010
2016
Some ( tc) => { return * tc; }
2011
2017
None => { }
2012
2018
}
2013
- match cx. tc_cache . find ( & ty_id) { // Must check both caches!
2014
- Some ( tc) => { return * tc; }
2015
- None => { }
2019
+ {
2020
+ let tc_cache = cx. tc_cache . borrow ( ) ;
2021
+ match tc_cache. get ( ) . find ( & ty_id) { // Must check both caches!
2022
+ Some ( tc) => { return * tc; }
2023
+ None => { }
2024
+ }
2016
2025
}
2017
2026
cache. insert ( ty_id, TC :: None ) ;
2018
2027
0 commit comments