Skip to content

Commit 78c36b9

Browse files
committed
Fixup: statics are always backed by an allocation
1 parent 9a63fc8 commit 78c36b9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/librustc_codegen_llvm/consts.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use libc::c_uint;
22
use llvm::{self, SetUnnamedAddr, True};
33
use rustc::hir::def_id::DefId;
4-
use rustc::mir::interpret::{ConstValue, Allocation, read_target_uint,
4+
use rustc::mir::interpret::{Allocation, read_target_uint,
55
Pointer, ErrorHandled, GlobalId};
66
use rustc::hir::Node;
77
use debuginfo;
@@ -69,12 +69,11 @@ pub fn codegen_static_initializer(
6969
};
7070
let param_env = ty::ParamEnv::reveal_all();
7171
let static_ = cx.tcx.const_eval(param_env.and(cid))?;
72-
let (alloc, ptr) = static_.alloc.unwrap();
73-
assert_eq!(ptr.offset.bytes(), 0);
74-
match static_.val {
75-
ConstValue::ByRef => {},
72+
let (alloc, ptr) = match static_.alloc {
73+
Some(alloc) => alloc,
7674
_ => bug!("static const eval returned {:#?}", static_),
77-
}
75+
};
76+
assert_eq!(ptr.offset.bytes(), 0);
7877
Ok((const_alloc_to_llvm(cx, alloc), alloc))
7978
}
8079

0 commit comments

Comments
 (0)