librustc: De-@mut
const_values
.
This commit is contained in:
parent
28943e96cb
commit
d16cca1f50
@ -2233,7 +2233,9 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
|
||||
"cannot have static_assert on a mutable \
|
||||
static");
|
||||
}
|
||||
let v = ccx.const_values.get_copy(&item.id);
|
||||
|
||||
let const_values = ccx.const_values.borrow();
|
||||
let v = const_values.get().get_copy(&item.id);
|
||||
unsafe {
|
||||
if !(llvm::LLVMConstIntGetZExtValue(v) != 0) {
|
||||
ccx.sess.span_fatal(expr.span, "static assertion failed");
|
||||
@ -2489,7 +2491,11 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
|
||||
// We need the translated value here, because for enums the
|
||||
// LLVM type is not fully determined by the Rust type.
|
||||
let (v, inlineable) = consts::const_expr(ccx, expr);
|
||||
ccx.const_values.insert(id, v);
|
||||
{
|
||||
let mut const_values = ccx.const_values
|
||||
.borrow_mut();
|
||||
const_values.get().insert(id, v);
|
||||
}
|
||||
let mut inlineable = inlineable;
|
||||
|
||||
unsafe {
|
||||
|
@ -157,7 +157,10 @@ fn const_deref(cx: &mut CrateContext, v: ValueRef, t: ty::t, explicit: bool)
|
||||
|
||||
pub fn get_const_val(cx: @mut CrateContext,
|
||||
mut def_id: ast::DefId) -> (ValueRef, bool) {
|
||||
let contains_key = cx.const_values.contains_key(&def_id.node);
|
||||
let contains_key = {
|
||||
let const_values = cx.const_values.borrow();
|
||||
const_values.get().contains_key(&def_id.node)
|
||||
};
|
||||
if !ast_util::is_local(def_id) || !contains_key {
|
||||
if !ast_util::is_local(def_id) {
|
||||
def_id = inline::maybe_instantiate_inline(cx, def_id);
|
||||
@ -171,7 +174,9 @@ pub fn get_const_val(cx: @mut CrateContext,
|
||||
_ => cx.tcx.sess.bug("expected a const to be an item")
|
||||
}
|
||||
}
|
||||
(cx.const_values.get_copy(&def_id.node),
|
||||
|
||||
let const_values = cx.const_values.borrow();
|
||||
(const_values.get().get_copy(&def_id.node),
|
||||
!cx.non_inlineable_statics.contains(&def_id.node))
|
||||
}
|
||||
|
||||
@ -642,7 +647,8 @@ pub fn trans_const(ccx: @mut CrateContext, m: ast::Mutability, id: ast::NodeId)
|
||||
let g = base::get_item_val(ccx, id);
|
||||
// At this point, get_item_val has already translated the
|
||||
// constant's initializer to determine its LLVM type.
|
||||
let v = ccx.const_values.get_copy(&id);
|
||||
let const_values = ccx.const_values.borrow();
|
||||
let v = const_values.get().get_copy(&id);
|
||||
llvm::LLVMSetInitializer(g, v);
|
||||
if m != ast::MutMutable {
|
||||
llvm::LLVMSetGlobalConstant(g, True);
|
||||
|
@ -84,7 +84,7 @@ pub struct CrateContext {
|
||||
const_globals: RefCell<HashMap<int, ValueRef>>,
|
||||
|
||||
// Cache of emitted const values
|
||||
const_values: HashMap<ast::NodeId, ValueRef>,
|
||||
const_values: RefCell<HashMap<ast::NodeId, ValueRef>>,
|
||||
|
||||
// Cache of external const values
|
||||
extern_const_values: HashMap<ast::DefId, ValueRef>,
|
||||
@ -199,7 +199,7 @@ impl CrateContext {
|
||||
vtables: RefCell::new(HashMap::new()),
|
||||
const_cstr_cache: RefCell::new(HashMap::new()),
|
||||
const_globals: RefCell::new(HashMap::new()),
|
||||
const_values: HashMap::new(),
|
||||
const_values: RefCell::new(HashMap::new()),
|
||||
extern_const_values: HashMap::new(),
|
||||
impl_method_cache: HashMap::new(),
|
||||
module_data: HashMap::new(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user