Skip to content

Commit 4a85b08

Browse files
committed
librustc: Stop trying to make invalid slice with vec in static.
1 parent c519474 commit 4a85b08

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/librustc/middle/trans/consts.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,16 @@ pub fn const_expr(cx: @mut CrateContext, e: @ast::expr) -> ValueRef {
211211
}
212212
ty::AutoBorrowVec(ty::re_static, m) => {
213213
assert!(m != ast::m_mutbl);
214-
let size = machine::llsize_of(cx,
215-
val_ty(llconst));
216214
assert_eq!(abi::slice_elt_base, 0);
217215
assert_eq!(abi::slice_elt_len, 1);
218-
llconst = C_struct([llptr, size]);
216+
217+
match ty::get(ty).sty {
218+
ty::ty_evec(_, ty::vstore_fixed(*)) => {
219+
let size = machine::llsize_of(cx, val_ty(llconst));
220+
llconst = C_struct([llptr, size]);
221+
}
222+
_ => {}
223+
}
219224
}
220225
_ => {
221226
cx.sess.span_bug(e.span,

0 commit comments

Comments
 (0)