diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-09-15 20:22:03 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2011-09-15 20:23:06 -0700 |
| commit | f41f75fe53b705d4363e91b8f66fd51e2b2f9fb5 (patch) | |
| tree | 8c59e4541b73fc39d3c084ad1b9b2a441a717865 /src/comp | |
| parent | 059952da5b18e475b6018c1d58e3b5099c57fdba (diff) | |
| download | rust-f41f75fe53b705d4363e91b8f66fd51e2b2f9fb5.tar.gz rust-f41f75fe53b705d4363e91b8f66fd51e2b2f9fb5.zip | |
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
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/middle/trans_common.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/comp/middle/trans_common.rs b/src/comp/middle/trans_common.rs index 9e9d55f19ce..32d0266c7e9 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 |
