@@ -941,29 +941,8 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
941
941
DatumBlock :: new ( bcx, datum. to_expr_datum ( ) )
942
942
}
943
943
def:: DefStatic ( did, _) => {
944
- // There are two things that may happen here:
945
- // 1) If the static item is defined in this crate, it will be
946
- // translated using `get_item_val`, and we return a pointer to
947
- // the result.
948
- // 2) If the static item is defined in another crate then we add
949
- // (or reuse) a declaration of an external global, and return a
950
- // pointer to that.
951
944
let const_ty = expr_ty ( bcx, ref_expr) ;
952
-
953
- // For external constants, we don't inline.
954
- let val = if let Some ( node_id) = bcx. tcx ( ) . map . as_local_node_id ( did) {
955
- // Case 1.
956
-
957
- // The LLVM global has the type of its initializer,
958
- // which may not be equal to the enum's type for
959
- // non-C-like enums.
960
- let val = base:: get_item_val ( bcx. ccx ( ) , node_id) ;
961
- let pty = type_of:: type_of ( bcx. ccx ( ) , const_ty) . ptr_to ( ) ;
962
- PointerCast ( bcx, val, pty)
963
- } else {
964
- // Case 2.
965
- base:: get_extern_const ( bcx. ccx ( ) , did, const_ty)
966
- } ;
945
+ let val = get_static_val ( bcx. ccx ( ) , did, const_ty) ;
967
946
let lval = Lvalue :: new ( "expr::trans_def" ) ;
968
947
DatumBlock :: new ( bcx, Datum :: new ( val, const_ty, LvalueExpr ( lval) ) )
969
948
}
0 commit comments