Skip to content

Commit 519db34

Browse files
committed
librustc: De-@mut CrateContext::tydescs
1 parent b5aa6eb commit 519db34

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,19 @@ pub fn get_tydesc_simple(ccx: &mut CrateContext, t: ty::t) -> ValueRef {
439439
}
440440

441441
pub fn get_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
442-
match ccx.tydescs.find(&t) {
443-
Some(&inf) => {
444-
return inf;
442+
{
443+
let tydescs = ccx.tydescs.borrow();
444+
match tydescs.get().find(&t) {
445+
Some(&inf) => return inf,
446+
_ => { }
445447
}
446-
_ => { }
447448
}
448449

449450
ccx.stats.n_static_tydescs += 1u;
450451
let inf = glue::declare_tydesc(ccx, t);
451-
ccx.tydescs.insert(t, inf);
452+
453+
let mut tydescs = ccx.tydescs.borrow_mut();
454+
tydescs.get().insert(t, inf);
452455
return inf;
453456
}
454457

src/librustc/middle/trans/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub struct CrateContext {
5252
reachable: @mut HashSet<ast::NodeId>,
5353
item_symbols: RefCell<HashMap<ast::NodeId, ~str>>,
5454
link_meta: LinkMeta,
55-
tydescs: HashMap<ty::t, @mut tydesc_info>,
55+
tydescs: RefCell<HashMap<ty::t, @mut tydesc_info>>,
5656
// Set when running emit_tydescs to enforce that no more tydescs are
5757
// created.
5858
finished_tydescs: bool,
@@ -188,7 +188,7 @@ impl CrateContext {
188188
reachable: reachable,
189189
item_symbols: RefCell::new(HashMap::new()),
190190
link_meta: link_meta,
191-
tydescs: HashMap::new(),
191+
tydescs: RefCell::new(HashMap::new()),
192192
finished_tydescs: false,
193193
external: HashMap::new(),
194194
external_srcs: HashMap::new(),

src/librustc/middle/trans/glue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,8 @@ pub fn emit_tydescs(ccx: &mut CrateContext) {
696696
// As of this point, allow no more tydescs to be created.
697697
ccx.finished_tydescs = true;
698698
let glue_fn_ty = Type::generic_glue_fn(ccx).ptr_to();
699-
let tyds = &mut ccx.tydescs;
700-
for (_, &val) in tyds.iter() {
699+
let mut tyds = ccx.tydescs.borrow_mut();
700+
for (_, &val) in tyds.get().iter() {
701701
let ti = val;
702702

703703
// Each of the glue functions needs to be cast to a generic type

0 commit comments

Comments
 (0)