From 85120d9959a367b0cfc1abb75acb0bec7a244ede Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 13 May 2011 18:46:16 -0700 Subject: [PATCH] rustc: Look types up in the side table --- src/comp/middle/ty.rs | 10 +++++----- src/comp/middle/typeck.rs | 9 ++++++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/comp/middle/ty.rs b/src/comp/middle/ty.rs index f28a8d62df5..599b3b213a0 100644 --- a/src/comp/middle/ty.rs +++ b/src/comp/middle/ty.rs @@ -1444,13 +1444,13 @@ fn eq_ty(&t a, &t b) -> bool { ret a == b; } fn ann_to_ty_param_substs_opt_and_ty(&node_type_table ntt, &ast::ann ann) -> ty_param_substs_opt_and_ty { - alt (ann) { - case (ast::ann_none(_)) { - log_err "ann_to_ty_param_substs_opt_and_ty() called on a node " + - "with no type params"; + alt (ntt.(ast::ann_tag(ann))) { + case (none[ty::ty_param_substs_opt_and_ty]) { + log_err "ann_to_ty_param_substs_opt_and_ty() called on an " + + "untyped node"; fail; } - case (ast::ann_type(_, ?t, ?tps, _)) { ret tup(tps, t); } + case (some[ty::ty_param_substs_opt_and_ty](?tpot)) { ret tpot; } } } diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 9487a0b0098..7f69b96f263 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -377,7 +377,7 @@ fn write_type(&node_type_table ntt, uint node_id, &ty_param_substs_opt_and_ty tpot) { _vec::grow_set[option::t[ty::ty_param_substs_opt_and_ty]] (*ntt, - 0u, + node_id, none[ty_param_substs_opt_and_ty], some[ty_param_substs_opt_and_ty](tpot)); } @@ -1745,6 +1745,9 @@ fn replace_expr_type(&node_type_table ntt, new_tps = none[vec[ty::t]]; } + write_type(ntt, ast::ann_tag(ty::expr_ann(expr)), + tup(new_tps, new_tyt._1)); + fn mkann_fn(ty::t tyt, option::t[vec[ty::t]] tps, &ast::ann old_ann) -> ast::ann { ret ast::ann_type(ast::ann_tag(old_ann), tyt, tps, none[@ts_ann]); @@ -2134,12 +2137,12 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) -> @ast::expr { if (ty::def_has_ty_params(defn)) { auto path_tpot = instantiate_path(fcx, pth, tpt, expr.span); + write_type(fcx.ccx.node_types, ast::ann_tag(old_ann), + path_tpot); ret @fold::respan[ast::expr_](expr.span, ast::expr_path(pth, ast::ann_type(ast::ann_tag(old_ann), path_tpot._1, path_tpot._0, none[@ts_ann]))); - write_type(fcx.ccx.node_types, ast::ann_tag(old_ann), - path_tpot); } // The definition doesn't take type parameters. If the programmer