Skip to content

Commit ba2e6c1

Browse files
committed
librustc: De-@mut the needs_unwind_cleanup_cache
1 parent 2e46ac6 commit ba2e6c1

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/librustc/middle/ty.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ struct ctxt_ {
308308
tcache: type_cache,
309309
rcache: creader_cache,
310310
short_names_cache: RefCell<HashMap<t, @str>>,
311-
needs_unwind_cleanup_cache: @mut HashMap<t, bool>,
311+
needs_unwind_cleanup_cache: RefCell<HashMap<t, bool>>,
312312
tc_cache: @mut HashMap<uint, TypeContents>,
313313
ast_ty_to_ty_cache: @mut HashMap<NodeId, ast_ty_to_ty_cache_entry>,
314314
enum_var_cache: @mut HashMap<DefId, @~[@VariantInfo]>,
@@ -994,7 +994,7 @@ pub fn mk_ctxt(s: session::Session,
994994
tcache: @mut HashMap::new(),
995995
rcache: mk_rcache(),
996996
short_names_cache: RefCell::new(HashMap::new()),
997-
needs_unwind_cleanup_cache: new_ty_hash(),
997+
needs_unwind_cleanup_cache: RefCell::new(HashMap::new()),
998998
tc_cache: @mut HashMap::new(),
999999
ast_ty_to_ty_cache: @mut HashMap::new(),
10001000
enum_var_cache: @mut HashMap::new(),
@@ -1668,15 +1668,21 @@ pub fn type_needs_drop(cx: ctxt, ty: t) -> bool {
16681668
// that only contain scalars and shared boxes can avoid unwind
16691669
// cleanups.
16701670
pub fn type_needs_unwind_cleanup(cx: ctxt, ty: t) -> bool {
1671-
match cx.needs_unwind_cleanup_cache.find(&ty) {
1672-
Some(&result) => return result,
1673-
None => ()
1671+
{
1672+
let needs_unwind_cleanup_cache = cx.needs_unwind_cleanup_cache
1673+
.borrow();
1674+
match needs_unwind_cleanup_cache.get().find(&ty) {
1675+
Some(&result) => return result,
1676+
None => ()
1677+
}
16741678
}
16751679

16761680
let mut tycache = HashSet::new();
16771681
let needs_unwind_cleanup =
16781682
type_needs_unwind_cleanup_(cx, ty, &mut tycache, false);
1679-
cx.needs_unwind_cleanup_cache.insert(ty, needs_unwind_cleanup);
1683+
let mut needs_unwind_cleanup_cache = cx.needs_unwind_cleanup_cache
1684+
.borrow_mut();
1685+
needs_unwind_cleanup_cache.get().insert(ty, needs_unwind_cleanup);
16801686
return needs_unwind_cleanup;
16811687
}
16821688

0 commit comments

Comments
 (0)