Removing dead code and redundant fails; changing fails to sess.bug

calls (issue #444).
This commit is contained in:
Lindsey Kuper 2011-06-07 13:50:30 -07:00
parent b1d6f12a05
commit ab69c4a98f
5 changed files with 93 additions and 158 deletions

View file

@ -3687,13 +3687,11 @@ fn autoderef(&@block_ctxt cx, ValueRef v, &ty::t t) -> result {
v1 = load_if_immediate(cx, v1, t1);
}
case (_) {
ret res(cx, v1);
}
case (_) { break; }
}
}
fail; // fools the return-checker
ret res(cx, v1);
}
fn autoderefed_ty(&@crate_ctxt ccx, &ty::t t) -> ty::t {
@ -3704,13 +3702,11 @@ fn autoderefed_ty(&@crate_ctxt ccx, &ty::t t) -> ty::t {
case (ty::ty_box(?mt)) {
t1 = mt.ty;
}
case (_) {
ret t1;
}
case (_) { break; }
}
}
fail; // fools the return-checker
ret t1;
}
fn trans_binary(&@block_ctxt cx, ast::binop op,
@ -3876,7 +3872,7 @@ fn trans_if(&@block_ctxt cx, &@ast::expr cond,
}
// FIXME: This isn't quite right, particularly re: dynamic types
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types,
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx,
ann);
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
@ -4260,7 +4256,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
case (ast::pat_lit(?lt, ?ann)) {
auto lllit = trans_lit(cx.fcx.lcx.ccx, *lt, ann);
auto lltype = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
auto lltype = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
auto lleq = trans_compare(cx, ast::eq, lltype, llval, lllit);
auto matched_cx = new_sub_block_ctxt(lleq.bcx, "matched_cx");
@ -4298,7 +4294,7 @@ fn trans_pat_match(&@block_ctxt cx, &@ast::pat pat, ValueRef llval,
cx.build.CondBr(lleq, matched_cx.llbb, next_cx.llbb);
auto ty_params =
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx.node_types, ann);
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx, ann);
if (vec::len[@ast::pat](subpats) > 0u) {
auto llblobptr = matched_cx.build.GEP(lltagptr,
@ -4359,7 +4355,7 @@ fn trans_pat_binding(&@block_ctxt cx, &@ast::pat pat,
auto llblobptr = cx.build.GEP(lltagptr, [C_int(0), C_int(1)]);
auto ty_param_substs =
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx.node_types, ann);
ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx, ann);
auto this_cx = cx;
auto i = 0;
@ -4408,7 +4404,7 @@ fn trans_alt(&@block_ctxt cx, &@ast::expr expr,
"non-exhaustive match failure");
// FIXME: This isn't quite right, particularly re: dynamic types
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
auto expr_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
auto expr_llty;
if (ty::type_has_dynamic_size(cx.fcx.lcx.ccx.tcx, expr_ty)) {
expr_llty = T_typaram_ptr(cx.fcx.lcx.ccx.tn);
@ -4473,8 +4469,8 @@ fn lval_generic_fn(&@block_ctxt cx,
lv = trans_external_path(cx, fn_id, tpt);
}
auto tys = ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx.node_types, ann);
auto monoty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
auto tys = ty::ann_to_type_params(cx.fcx.lcx.ccx.tcx, ann);
auto monoty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
if (vec::len[ty::t](tys) != 0u) {
auto bcx = lv.res.bcx;
@ -5361,7 +5357,7 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f,
}
auto ret_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx.node_types, ann);
auto ret_ty = ty::ann_to_type(cx.fcx.lcx.ccx.tcx, ann);
auto args_res = trans_args(f_res.res.bcx,
llenv, f_res.llobj,
f_res.generic,
@ -6910,7 +6906,7 @@ fn is_terminated(&@block_ctxt cx) -> bool {
}
fn arg_tys_of_fn(&@crate_ctxt ccx, ast::ann ann) -> vec[ty::arg] {
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx.node_types, ann))) {
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx, ann))) {
case (ty::ty_fn(_, ?arg_tys, _, _)) {
ret arg_tys;
}
@ -6927,7 +6923,7 @@ fn ret_ty_of_fn_ty(&@crate_ctxt ccx, ty::t t) -> ty::t {
fn ret_ty_of_fn(&@crate_ctxt ccx, ast::ann ann) -> ty::t {
ret ret_ty_of_fn_ty(ccx, ty::ann_to_type(ccx.tcx.node_types, ann));
ret ret_ty_of_fn_ty(ccx, ty::ann_to_type(ccx.tcx, ann));
}
fn populate_fn_ctxt_from_llself(@fn_ctxt fcx, val_self_pair llself) {

View file

@ -482,7 +482,7 @@ fn controlflow_def_id(&crate_ctxt ccx, &def_id d) -> controlflow {
If it has a function type with a ! annotation,
the answer is noreturn. */
fn controlflow_expr(&crate_ctxt ccx, @expr e) -> controlflow {
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx.node_types,
alt (ty::struct(ccx.tcx, ty::ann_to_type(ccx.tcx,
expr_ann(e)))) {
case (ty::ty_fn(_,_,_,?cf)) {
ret cf;

View file

@ -921,9 +921,7 @@ fn sequence_element_type(&ctxt cx, &t ty) -> t {
// NB: This is not exhaustive.
}
// FIXME: add sess.err or sess.span_err explaining failure (issue
// #444)
fail;
cx.sess.bug("sequence_element_type called on non-sequence value");
}
fn type_is_tup_like(&ctxt cx, &t ty) -> bool {
@ -949,8 +947,8 @@ fn get_element_type(&ctxt cx, &t ty, uint i) -> t {
// tag.
}
// FIXME: add sess.err or sess.span_err explaining failure (issue #444)
fail;
cx.sess.bug("get_element_type called on a value other than a "
+ "tuple or record");
}
fn type_is_box(&ctxt cx, &t ty) -> bool {
@ -1544,24 +1542,25 @@ fn eq_ty(&t a, &t b) -> bool { ret a == b; }
// Type lookups
fn ann_to_ty_param_substs_opt_and_ty(&node_type_table ntt, &ast::ann ann)
-> ty_param_substs_opt_and_ty {
alt ({ntt.(ann.id)}) {
fn ann_to_ty_param_substs_opt_and_ty(&ty_ctxt tcx, &ast::ann ann)
-> ty_param_substs_opt_and_ty {
// Pull out the node type table.
alt ({tcx.node_types.(ann.id)}) {
case (none) {
log_err "ann_to_ty_param_substs_opt_and_ty() called on an " +
"untyped node";
fail;
tcx.sess.bug("ann_to_ty_param_substs_opt_and_ty() called on an " +
"untyped node");
}
case (some(?tpot)) { ret tpot; }
}
}
fn ann_to_type(&node_type_table ntt, &ast::ann ann) -> t {
ret ann_to_ty_param_substs_opt_and_ty(ntt, ann)._1;
fn ann_to_type(&ty_ctxt tcx, &ast::ann ann) -> t {
ret ann_to_ty_param_substs_opt_and_ty(tcx, ann)._1;
}
fn ann_to_type_params(&node_type_table ntt, &ast::ann ann) -> vec[t] {
alt (ann_to_ty_param_substs_opt_and_ty(ntt, ann)._0) {
fn ann_to_type_params(&ty_ctxt tcx, &ast::ann ann) -> vec[t] {
alt (ann_to_ty_param_substs_opt_and_ty(tcx, ann)._0) {
case (none) {
let vec[t] result = [];
ret result;
@ -1570,8 +1569,8 @@ fn ann_to_type_params(&node_type_table ntt, &ast::ann ann) -> vec[t] {
}
}
fn ann_has_type_params(&node_type_table ntt, &ast::ann ann) -> bool {
auto tpt = ann_to_ty_param_substs_opt_and_ty(ntt, ann);
fn ann_has_type_params(&ty_ctxt tcx, &ast::ann ann) -> bool {
auto tpt = ann_to_ty_param_substs_opt_and_ty(tcx, ann);
ret !option::is_none[vec[t]](tpt._0);
}
@ -1579,7 +1578,7 @@ fn ann_has_type_params(&node_type_table ntt, &ast::ann ann) -> bool {
// Returns the type of an annotation, with type parameter substitutions
// performed if applicable.
fn ann_to_monotype(&ctxt cx, ast::ann a) -> t {
auto tpot = ann_to_ty_param_substs_opt_and_ty(cx.node_types, a);
auto tpot = ann_to_ty_param_substs_opt_and_ty(cx, a);
alt (tpot._0) {
case (none) { ret tpot._1; }
case (some(?tps)) {
@ -1638,21 +1637,21 @@ fn ty_fn_args(&ctxt cx, &t fty) -> vec[arg] {
case (ty::ty_fn(_, ?a, _, _)) { ret a; }
case (ty::ty_native_fn(_, ?a, _)) { ret a; }
}
fail;
cx.sess.bug("ty_fn_args() called on non-fn type");
}
fn ty_fn_proto(&ctxt cx, &t fty) -> ast::proto {
alt (struct(cx, fty)) {
case (ty::ty_fn(?p, _, _, _)) { ret p; }
}
fail;
cx.sess.bug("ty_fn_proto() called on non-fn type");
}
fn ty_fn_abi(&ctxt cx, &t fty) -> ast::native_abi {
alt (struct(cx, fty)) {
case (ty::ty_native_fn(?a, _, _)) { ret a; }
}
fail;
cx.sess.bug("ty_fn_abi() called on non-native-fn type");
}
fn ty_fn_ret(&ctxt cx, &t fty) -> t {
@ -1660,7 +1659,7 @@ fn ty_fn_ret(&ctxt cx, &t fty) -> t {
case (ty::ty_fn(_, _, ?r, _)) { ret r; }
case (ty::ty_native_fn(_, _, ?r)) { ret r; }
}
fail;
cx.sess.bug("ty_fn_ret() called on non-fn type");
}
fn is_fn_ty(&ctxt cx, &t fty) -> bool {
@ -1674,66 +1673,8 @@ fn is_fn_ty(&ctxt cx, &t fty) -> bool {
// Type accessors for AST nodes
// Given an item, returns the associated type as well as the number of type
// parameters it has.
fn native_item_ty(&node_type_table ntt, &@ast::native_item it)
-> ty_param_count_and_ty {
auto ty_param_count;
auto result_ty;
alt (it.node) {
case (ast::native_item_fn(_, _, _, ?tps, _, ?ann)) {
ty_param_count = vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ntt, ann);
}
}
ret tup(ty_param_count, result_ty);
}
fn item_ty(&node_type_table ntt, &@ast::item it) -> ty_param_count_and_ty {
auto ty_param_count;
auto result_ty;
alt (it.node) {
case (ast::item_const(_, _, _, _, ?ann)) {
ty_param_count = 0u;
result_ty = ann_to_type(ntt, ann);
}
case (ast::item_fn(_, _, ?tps, _, ?ann)) {
ty_param_count = vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ntt, ann);
}
case (ast::item_mod(_, _, _)) {
fail; // modules are typeless
}
case (ast::item_ty(_, _, ?tps, _, ?ann)) {
ty_param_count = vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ntt, ann);
}
case (ast::item_tag(_, _, ?tps, ?did, ?ann)) {
ty_param_count = vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ntt, ann);
}
case (ast::item_obj(_, _, ?tps, _, ?ann)) {
ty_param_count = vec::len[ast::ty_param](tps);
result_ty = ann_to_type(ntt, ann);
}
}
ret tup(ty_param_count, result_ty);
}
fn stmt_ty(&ctxt cx, &@ast::stmt s) -> t {
alt (s.node) {
case (ast::stmt_expr(?e,_)) {
ret expr_ty(cx, e);
}
case (_) {
ret mk_nil(cx);
}
}
}
fn block_ty(&ctxt cx, &ast::block b) -> t {
ret ann_to_type(cx.node_types, b.node.a);
ret ann_to_type(cx, b.node.a);
}
// Returns the type of a pattern as a monotype. Like @expr_ty, this function
@ -1820,18 +1761,18 @@ fn expr_ty_params_and_ty(&ctxt cx, &@ast::expr expr)
-> tup(vec[t], t) {
auto a = expr_ann(expr);
ret tup(ann_to_type_params(cx.node_types, a),
ann_to_type(cx.node_types, a));
ret tup(ann_to_type_params(cx, a),
ann_to_type(cx, a));
}
fn expr_has_ty_params(&node_type_table ntt, &@ast::expr expr) -> bool {
ret ann_has_type_params(ntt, expr_ann(expr));
fn expr_has_ty_params(&ty_ctxt tcx, &@ast::expr expr) -> bool {
ret ann_has_type_params(tcx, expr_ann(expr));
}
fn decl_local_ty(&ctxt cx, &@ast::decl d) -> t {
alt (d.node) {
case (ast::decl_local(?l)) {
ret ann_to_type(cx.node_types, l.ann);
ret ann_to_type(cx, l.ann);
}
case (_) {
cx.sess.bug("decl_local_ty called on an item decl");
@ -2281,8 +2222,9 @@ mod unify {
case (ty::ty_bound_param(?actual_id)) {
alt (struct(cx.tcx, expected)) {
case (ty::ty_local(_)) {
log_err "TODO: bound param unifying with local";
fail;
// TODO: bound param unifying with local
cx.tcx.sess.unimpl("TODO: bound param unifying with "
+ "local");
}
case (_) {
@ -2686,18 +2628,15 @@ mod unify {
}
fn unify_sets[T](&ty_ctxt tcx, &@bindings[T] bindings) -> set_result {
obj handler() {
obj handler(ty_ctxt tcx) {
fn resolve_local(ast::def_id id) -> option::t[t] {
log_err "resolve_local in unify_sets";
fail;
tcx.sess.bug("resolve_local in unify_sets");
}
fn record_local(ast::def_id id, t ty) {
log_err "record_local in unify_sets";
fail;
tcx.sess.bug("record_local in unify_sets");
}
fn record_param(uint index, t binding) -> unify::result {
log_err "record_param in unify_sets";
fail;
tcx.sess.bug("record_param in unify_sets");
}
}
@ -2718,8 +2657,8 @@ mod unify {
// FIXME: Is this right?
auto bindings = mk_bindings[int](int::hash,
int::eq_alias);
alt (unify(expected, actual, handler(), bindings,
tcx)) {
alt (unify(expected, actual, handler(tcx),
bindings, tcx)) {
case (ures_ok(?result_ty)) {
results.(i) = some[t](result_ty);
}
@ -2840,9 +2779,8 @@ fn bind_params_in_type(&ctxt cx, &t typ) -> t {
fn binder(&ctxt cx, t typ) -> t {
alt (struct(cx, typ)) {
case (ty_bound_param(?index)) {
log_err "bind_params_in_type() called on type that already " +
"has bound params in it";
fail;
cx.sess.bug("bind_params_in_type() called on type that "
+ "already has bound params in it");
}
case (ty_param(?index)) { ret mk_bound_param(cx, index); }
case (_) { ret typ; }
@ -2924,9 +2862,9 @@ fn tag_variant_with_id(&ctxt cx,
}
i += 1u;
}
cx.sess.bug("tag_variant_with_id(): no variant exists with that ID");
log_err "tag_variant_with_id(): no variant exists with that ID";
fail;
}
// If the given item is in an external crate, looks up its type and adds it to
@ -2954,13 +2892,13 @@ fn ret_ty_of_fn_ty(ty_ctxt tcx, t a_ty) -> t {
ret ret_ty;
}
case (_) {
fail;
tcx.sess.bug("ret_ty_of_fn_ty() called on non-function type");
}
}
}
fn ret_ty_of_fn(ty_ctxt tcx, ast::ann ann) -> t {
ret ret_ty_of_fn_ty(tcx, ann_to_type(tcx.node_types, ann));
ret ret_ty_of_fn_ty(tcx, ann_to_type(tcx, ann));
}
// Local Variables:

View file

@ -1116,7 +1116,7 @@ mod pushdown {
// TODO: enforce mutability
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
alt (struct(scx.fcx.ccx.tcx, t)) {
case (ty::ty_vec(?mt)) {
for (@ast::expr e_0 in es_0) {
@ -1132,7 +1132,7 @@ mod pushdown {
}
case (ast::expr_tup(?es_0, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
alt (struct(scx.fcx.ccx.tcx, t)) {
case (ty::ty_tup(?mts)) {
auto i = 0u;
@ -1151,7 +1151,7 @@ mod pushdown {
case (ast::expr_rec(?fields_0, ?base_0, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
alt (struct(scx.fcx.ccx.tcx, t)) {
case (ty::ty_rec(?field_mts)) {
alt (base_0) {
@ -1192,7 +1192,7 @@ mod pushdown {
}
case (ast::expr_bind(?sube, ?es, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_call(?sube, ?es, ?ann)) {
@ -1201,24 +1201,24 @@ mod pushdown {
// produce a box; things like expr_binary or expr_bind can't,
// so there's no need.
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_self_method(?id, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_binary(?bop, ?lhs, ?rhs, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_unary(?uop, ?sube, ?ann)) {
// See note in expr_unary for why we're calling
// demand::autoderef.
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
/* The following is a bit special-cased, but takes care of
@ -1248,17 +1248,17 @@ mod pushdown {
}
case (ast::expr_lit(?lit, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_cast(?sube, ?ast_ty, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_if(?cond, ?then_0, ?else_0, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
auto then_t = ty::block_ty(scx.fcx.ccx.tcx, then_0);
pushdown_block(scx, expected, then_0);
@ -1274,65 +1274,65 @@ mod pushdown {
}
case (ast::expr_for(?decl, ?seq, ?bloc, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_for_each(?decl, ?seq, ?bloc, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_while(?cond, ?bloc, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_do_while(?bloc, ?cond, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_block(?bloc, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
pushdown_block(scx, t, bloc);
}
case (ast::expr_move(?lhs_0, ?rhs_0, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
pushdown_expr(scx, expected, lhs_0);
pushdown_expr(scx, expected, rhs_0);
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_assign(?lhs_0, ?rhs_0, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
pushdown_expr(scx, expected, lhs_0);
pushdown_expr(scx, expected, rhs_0);
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_assign_op(?op, ?lhs_0, ?rhs_0, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
pushdown_expr(scx, expected, lhs_0);
pushdown_expr(scx, expected, rhs_0);
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_field(?lhs, ?rhs, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_index(?base, ?index, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_path(?pth, ?ann)) {
auto tp_substs_0 =
ty::ann_to_type_params(scx.fcx.ccx.tcx.node_types, ann);
auto t_0 = ann_to_type(scx.fcx.ccx.tcx.node_types, ann);
ty::ann_to_type_params(scx.fcx.ccx.tcx, ann);
auto t_0 = ann_to_type(scx.fcx.ccx.tcx, ann);
auto result_0 = demand::full(scx, e.span, expected, t_0,
tp_substs_0, adk);
@ -1341,8 +1341,9 @@ mod pushdown {
// Fill in the type parameter substitutions if they weren't
// provided by the programmer.
auto ty_params_opt;
alt (ty::ann_to_ty_param_substs_opt_and_ty
(scx.fcx.ccx.tcx.node_types, ann)._0) {
(scx.fcx.ccx.tcx, ann)._0) {
case (none) {
ty_params_opt = none[vec[ty::t]];
}
@ -1355,7 +1356,7 @@ mod pushdown {
}
case (ast::expr_ext(?p, ?args, ?body, ?expanded, ?ann)) {
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
}
/* FIXME: should this check the type annotations? */
@ -1371,13 +1372,13 @@ mod pushdown {
case (ast::expr_port(?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
write::ty_only_fixup(scx, ann.id, t);
}
case (ast::expr_chan(?es, ?ann)) {
auto t = demand::simple(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann));
ann_to_type(scx.fcx.ccx.tcx, ann));
alt (struct(scx.fcx.ccx.tcx, t)) {
case (ty::ty_chan(?subty)) {
auto pt = ty::mk_port(scx.fcx.ccx.tcx, subty);
@ -1419,7 +1420,7 @@ mod pushdown {
// produce a box; things like expr_binary or expr_bind can't,
// so there's no need.
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
}
@ -1427,7 +1428,7 @@ mod pushdown {
// NB: Not sure if this is correct, but not worrying too much
// about it since pushdown is going away anyway.
auto t = demand::autoderef(scx, e.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, ann), adk);
ann_to_type(scx.fcx.ccx.tcx, ann), adk);
write::ty_only_fixup(scx, ann.id, t);
}
@ -1450,7 +1451,7 @@ mod pushdown {
}
}
demand::simple(scx, bloc.span, expected,
ann_to_type(scx.fcx.ccx.tcx.node_types, bloc.node.a));
ann_to_type(scx.fcx.ccx.tcx, bloc.node.a));
}
}
@ -1488,7 +1489,7 @@ mod writeback {
}
auto tpot =
ty::ann_to_ty_param_substs_opt_and_ty(fcx.ccx.tcx.node_types,
ty::ann_to_ty_param_substs_opt_and_ty(fcx.ccx.tcx,
ann);
auto tt = tpot._1;
if (!ty::type_contains_locals(fcx.ccx.tcx, tt)) { ret; }
@ -1553,7 +1554,7 @@ fn replace_expr_type(&@stmt_ctxt scx,
&@ast::expr expr,
&tup(vec[ty::t], ty::t) new_tyt) {
auto new_tps;
if (ty::expr_has_ty_params(scx.fcx.ccx.tcx.node_types, expr)) {
if (ty::expr_has_ty_params(scx.fcx.ccx.tcx, expr)) {
new_tps = some[vec[ty::t]](new_tyt._0);
} else {
new_tps = none[vec[ty::t]];
@ -2722,7 +2723,7 @@ fn check_block(&@stmt_ctxt scx, &ast::block block) {
fn check_const(&@crate_ctxt ccx, &span sp, &@ast::expr e, &ast::ann ann) {
// FIXME: this is kinda a kludge; we manufacture a fake function context
// and statement context for checking the initializer expression.
auto rty = ann_to_type(ccx.tcx.node_types, ann);
auto rty = ann_to_type(ccx.tcx, ann);
let @fn_ctxt fcx = @rec(ret_ty = rty,
purity = ast::pure_fn,
locals = @common::new_def_hash[ty::t](),
@ -2742,7 +2743,7 @@ fn check_fn(&@crate_ctxt ccx, &ast::fn_decl decl, ast::proto proto,
alt (get_obj_info(ccx)) {
case (option::some(?oinfo)) {
for (ast::obj_field f in oinfo.obj_fields) {
auto field_ty = ty::ann_to_type(ccx.tcx.node_types, f.ann);
auto field_ty = ty::ann_to_type(ccx.tcx, f.ann);
local_ty_table.insert(f.id, field_ty);
}
}

View file

@ -945,7 +945,7 @@ fn print_decl(&ps s, &@ast::decl decl) {
case (mo_untyped) { /* no-op */ }
case (mo_typed(?tcx)) {
auto lty =
ty::ann_to_type(tcx.node_types, loc.ann);
ty::ann_to_type(tcx, loc.ann);
word_space(s, ty::ty_to_str(tcx, lty));
}
case (mo_identified) { /* no-op */ }