Skip to content

Commit a5db84c

Browse files
committed
librustc: De-@mut the extern_const_statics table in the type context
1 parent 55a7b2f commit a5db84c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/librustc/middle/const_eval.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,12 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
154154
Some(_) => None
155155
}
156156
} else {
157-
match tcx.extern_const_statics.find(&def_id) {
158-
Some(&e) => return e,
159-
None => {}
157+
{
158+
let extern_const_statics = tcx.extern_const_statics.borrow();
159+
match extern_const_statics.get().find(&def_id) {
160+
Some(&e) => return e,
161+
None => {}
162+
}
160163
}
161164
let maps = astencode::Maps {
162165
root_map: @mut HashMap::new(),
@@ -173,8 +176,12 @@ pub fn lookup_const_by_id(tcx: ty::ctxt,
173176
},
174177
_ => None
175178
};
176-
tcx.extern_const_statics.insert(def_id, e);
177-
return e;
179+
{
180+
let mut extern_const_statics = tcx.extern_const_statics
181+
.borrow_mut();
182+
extern_const_statics.get().insert(def_id, e);
183+
return e;
184+
}
178185
}
179186
}
180187

src/librustc/middle/ty.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ struct ctxt_ {
368368

369369
// These two caches are used by const_eval when decoding external statics
370370
// and variants that are found.
371-
extern_const_statics: @mut HashMap<ast::DefId, Option<@ast::Expr>>,
371+
extern_const_statics: RefCell<HashMap<ast::DefId, Option<@ast::Expr>>>,
372372
extern_const_variants: @mut HashMap<ast::DefId, Option<@ast::Expr>>,
373373
}
374374

@@ -1014,7 +1014,7 @@ pub fn mk_ctxt(s: session::Session,
10141014
populated_external_types: @mut HashSet::new(),
10151015
populated_external_traits: @mut HashSet::new(),
10161016

1017-
extern_const_statics: @mut HashMap::new(),
1017+
extern_const_statics: RefCell::new(HashMap::new()),
10181018
extern_const_variants: @mut HashMap::new(),
10191019
}
10201020
}

0 commit comments

Comments
 (0)