Skip to content

Commit 85120d9

Browse files
committed
rustc: Look types up in the side table
1 parent 6997adf commit 85120d9

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

Diff for: src/comp/middle/ty.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1444,13 +1444,13 @@ fn eq_ty(&t a, &t b) -> bool { ret a == b; }
14441444

14451445
fn ann_to_ty_param_substs_opt_and_ty(&node_type_table ntt, &ast::ann ann)
14461446
-> ty_param_substs_opt_and_ty {
1447-
alt (ann) {
1448-
case (ast::ann_none(_)) {
1449-
log_err "ann_to_ty_param_substs_opt_and_ty() called on a node " +
1450-
"with no type params";
1447+
alt (ntt.(ast::ann_tag(ann))) {
1448+
case (none[ty::ty_param_substs_opt_and_ty]) {
1449+
log_err "ann_to_ty_param_substs_opt_and_ty() called on an " +
1450+
"untyped node";
14511451
fail;
14521452
}
1453-
case (ast::ann_type(_, ?t, ?tps, _)) { ret tup(tps, t); }
1453+
case (some[ty::ty_param_substs_opt_and_ty](?tpot)) { ret tpot; }
14541454
}
14551455
}
14561456

Diff for: src/comp/middle/typeck.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ fn write_type(&node_type_table ntt, uint node_id,
377377
&ty_param_substs_opt_and_ty tpot) {
378378
_vec::grow_set[option::t[ty::ty_param_substs_opt_and_ty]]
379379
(*ntt,
380-
0u,
380+
node_id,
381381
none[ty_param_substs_opt_and_ty],
382382
some[ty_param_substs_opt_and_ty](tpot));
383383
}
@@ -1745,6 +1745,9 @@ fn replace_expr_type(&node_type_table ntt,
17451745
new_tps = none[vec[ty::t]];
17461746
}
17471747

1748+
write_type(ntt, ast::ann_tag(ty::expr_ann(expr)),
1749+
tup(new_tps, new_tyt._1));
1750+
17481751
fn mkann_fn(ty::t tyt, option::t[vec[ty::t]] tps, &ast::ann old_ann)
17491752
-> ast::ann {
17501753
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 {
21342137

21352138
if (ty::def_has_ty_params(defn)) {
21362139
auto path_tpot = instantiate_path(fcx, pth, tpt, expr.span);
2140+
write_type(fcx.ccx.node_types, ast::ann_tag(old_ann),
2141+
path_tpot);
21372142
ret @fold::respan[ast::expr_](expr.span,
21382143
ast::expr_path(pth,
21392144
ast::ann_type(ast::ann_tag(old_ann), path_tpot._1,
21402145
path_tpot._0, none[@ts_ann])));
2141-
write_type(fcx.ccx.node_types, ast::ann_tag(old_ann),
2142-
path_tpot);
21432146
}
21442147

21452148
// The definition doesn't take type parameters. If the programmer

0 commit comments

Comments
 (0)