From f41f75fe53b705d4363e91b8f66fd51e2b2f9fb5 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 15 Sep 2011 20:22:03 -0700 Subject: [PATCH] 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 --- src/comp/middle/trans_common.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index 9e9d55f19ceb..32d0266c7e90 100644 --- a/src/comp/middle/trans_common.rs +++ b/src/comp/middle/trans_common.rs @@ -335,9 +335,12 @@ fn get_res_dtor(ccx: @crate_ctxt, sp: span, did: ast::def_id, inner_t: ty::t) } let params = csearch::get_type_param_count(ccx.sess.get_cstore(), did); + let nil_res = ty::mk_nil(ccx.tcx); + // FIXME: Silly check -- mk_nil should have a postcondition + check non_ty_var(ccx, nil_res); let f_t = type_of_fn(ccx, sp, ast::proto_fn, false, false, [{mode: ast::by_ref, ty: inner_t}], - ty::mk_nil(ccx.tcx), params); + nil_res, params); ret trans::get_extern_const(ccx.externs, ccx.llmod, csearch::get_symbol(ccx.sess.get_cstore(), did), @@ -412,7 +415,7 @@ fn extend_path(cx: @local_ctxt, name: str) -> @local_ctxt { } fn rslt(bcx: @block_ctxt, val: ValueRef) -> result { - ret {bcx: bcx, val: val}; + {bcx: bcx, val: val} } 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 { !ty::type_has_dynamic_size(cx.tcx, t) } +pure fn non_ty_var(cx: @crate_ctxt, t: ty::t) -> bool { + // Not obviously referentially transparent, but + // type interner shouldn't be changing at this point. + // FIXME: how to make that clearer? + let st = unchecked { ty::struct(cx.tcx, t) }; + alt st { + ty::ty_var(_) { false } + _ { true } + } +} + // // Local Variables: // mode: rust