Skip to content

Commit d546493

Browse files
committed
auto merge of #6380 : pcwalton/rust/core-text-ice, r=pcwalton
2 parents dba9337 + 923450d commit d546493

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/librustc/middle/trans/expr.rs

+21-19
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,10 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
968968
}
969969

970970
fn get_val(bcx: block, did: ast::def_id, const_ty: ty::t)
971-
-> ValueRef {
971+
-> ValueRef {
972+
// For external constants, we don't inline.
973+
let extern_const_values =
974+
&mut *bcx.ccx().extern_const_values;
972975
if did.crate == ast::local_crate {
973976
// The LLVM global has the type of its initializer,
974977
// which may not be equal to the enum's type for
@@ -977,25 +980,24 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
977980
base::get_item_val(bcx.ccx(), did.node),
978981
T_ptr(type_of(bcx.ccx(), const_ty)))
979982
} else {
980-
// For external constants, we don't inline.
981-
match bcx.ccx().extern_const_values.find(&did) {
982-
None => {
983-
unsafe {
984-
let llty = type_of(bcx.ccx(), const_ty);
985-
let symbol = csearch::get_symbol(
986-
bcx.ccx().sess.cstore,
987-
did);
988-
let llval = llvm::LLVMAddGlobal(
989-
bcx.ccx().llmod,
990-
llty,
991-
transmute::<&u8,*i8>(&symbol[0]));
992-
bcx.ccx().extern_const_values.insert(
993-
did,
994-
llval);
995-
llval
996-
}
983+
match extern_const_values.find(&did) {
984+
None => {} // Continue.
985+
Some(llval) => {
986+
return *llval;
997987
}
998-
Some(llval) => *llval
988+
}
989+
990+
unsafe {
991+
let llty = type_of(bcx.ccx(), const_ty);
992+
let symbol = csearch::get_symbol(
993+
bcx.ccx().sess.cstore,
994+
did);
995+
let llval = llvm::LLVMAddGlobal(
996+
bcx.ccx().llmod,
997+
llty,
998+
transmute::<&u8,*i8>(&symbol[0]));
999+
extern_const_values.insert(did, llval);
1000+
llval
9991001
}
10001002
}
10011003
}

0 commit comments

Comments
 (0)