Skip to content

Commit 8613f28

Browse files
committed
In trans, replace another impossible case with a precondition
1 parent 1002623 commit 8613f28

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/comp/middle/trans.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,19 @@ fn type_of_inner(cx: @crate_ctxt, sp: span, t: ty::t)
224224
ret llty;
225225
}
226226

227-
fn type_of_tag(cx: @crate_ctxt, sp: span, did: ast::def_id, t: ty::t) ->
228-
TypeRef {
227+
fn type_of_tag(cx: @crate_ctxt, sp: span, did: ast::def_id, t: ty::t)
228+
-> TypeRef {
229229
let degen = std::vec::len(ty::tag_variants(cx.tcx, did)) == 1u;
230-
if ty::type_has_dynamic_size(cx.tcx, t) {
231-
if degen { ret T_i8(); } else { ret T_opaque_tag(cx.tn); }
232-
} else {
230+
if check type_has_static_size(cx, t) {
233231
let size = static_size_of_tag(cx, sp, t);
234232
if !degen { ret T_tag(cx.tn, size); }
235233
// LLVM does not like 0-size arrays, apparently
236234
if size == 0u { size = 1u; }
237235
ret T_array(T_i8(), size);
238236
}
237+
else {
238+
if degen { ret T_i8(); } else { ret T_opaque_tag(cx.tn); }
239+
}
239240
}
240241

241242
fn type_of_ty_param_kinds_and_ty(lcx: @local_ctxt, sp: span,
@@ -503,12 +504,8 @@ fn simplify_type(ccx: @crate_ctxt, typ: ty::t) -> ty::t {
503504

504505

505506
// Computes the size of the data part of a non-dynamically-sized tag.
506-
fn static_size_of_tag(cx: @crate_ctxt, sp: span, t: ty::t) -> uint {
507-
if ty::type_has_dynamic_size(cx.tcx, t) {
508-
cx.tcx.sess.span_fatal(sp,
509-
"dynamically sized type passed to \
510-
static_size_of_tag()");
511-
}
507+
fn static_size_of_tag(cx: @crate_ctxt, sp: span, t: ty::t)
508+
: type_has_static_size(cx, t) -> uint {
512509
if cx.tag_sizes.contains_key(t) { ret cx.tag_sizes.get(t); }
513510
alt ty::struct(cx.tcx, t) {
514511
ty::ty_tag(tid, subtys) {

0 commit comments

Comments
 (0)