Skip to content

Commit f41f75f

Browse files
committed
Added more predicates in trans
Added the non_ty_var predicate (soon to be used) Added a check in get_res_dtor (will be necessary for a future change to type_of_fn) Removed a gratuitous ret
1 parent 059952d commit f41f75f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/comp/middle/trans_common.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,12 @@ fn get_res_dtor(ccx: @crate_ctxt, sp: span, did: ast::def_id, inner_t: ty::t)
335335
}
336336

337337
let params = csearch::get_type_param_count(ccx.sess.get_cstore(), did);
338+
let nil_res = ty::mk_nil(ccx.tcx);
339+
// FIXME: Silly check -- mk_nil should have a postcondition
340+
check non_ty_var(ccx, nil_res);
338341
let f_t = type_of_fn(ccx, sp, ast::proto_fn, false, false,
339342
[{mode: ast::by_ref, ty: inner_t}],
340-
ty::mk_nil(ccx.tcx), params);
343+
nil_res, params);
341344
ret trans::get_extern_const(ccx.externs, ccx.llmod,
342345
csearch::get_symbol(ccx.sess.get_cstore(),
343346
did),
@@ -412,7 +415,7 @@ fn extend_path(cx: @local_ctxt, name: str) -> @local_ctxt {
412415
}
413416

414417
fn rslt(bcx: @block_ctxt, val: ValueRef) -> result {
415-
ret {bcx: bcx, val: val};
418+
{bcx: bcx, val: val}
416419
}
417420

418421
fn ty_str(tn: type_names, t: TypeRef) -> str {
@@ -843,6 +846,17 @@ pure fn type_has_static_size(cx: @crate_ctxt, t: ty::t) -> bool {
843846
!ty::type_has_dynamic_size(cx.tcx, t)
844847
}
845848

849+
pure fn non_ty_var(cx: @crate_ctxt, t: ty::t) -> bool {
850+
// Not obviously referentially transparent, but
851+
// type interner shouldn't be changing at this point.
852+
// FIXME: how to make that clearer?
853+
let st = unchecked { ty::struct(cx.tcx, t) };
854+
alt st {
855+
ty::ty_var(_) { false }
856+
_ { true }
857+
}
858+
}
859+
846860
//
847861
// Local Variables:
848862
// mode: rust

0 commit comments

Comments
 (0)