Skip to content

Commit c3fb894

Browse files
committed
---
yaml --- r: 1133 b: refs/heads/master c: e06263f h: refs/heads/master i: 1131: 1230ac6 v: v3
1 parent d8e6735 commit c3fb894

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 3504f4a4bf492886aa6cc7b2eae5d8e0100e9d51
2+
refs/heads/master: e06263ff4bb2fcdb39d28a65dd14438809fc83b3

trunk/src/comp/middle/typeck.rs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ fn collect_item_types(@ast.crate crate) -> tup(@ast.crate, @ty_table) {
513513

514514
// Type unification
515515

516-
fn unify(&fn_ctxt fcx, @ty.t expected, @ty.t actual) -> unify_result {
516+
fn unify(&@fn_ctxt fcx, @ty.t expected, @ty.t actual) -> unify_result {
517517
// Wraps the given type in an appropriate cname.
518518
//
519519
// TODO: This doesn't do anything yet. We should carry the cname up from
@@ -530,7 +530,7 @@ fn unify(&fn_ctxt fcx, @ty.t expected, @ty.t actual) -> unify_result {
530530
ret ures_err(terr_mismatch, expected, actual);
531531
}
532532

533-
fn unify_step(&fn_ctxt fcx, &hashmap[int,@ty.t] bindings, @ty.t expected,
533+
fn unify_step(&@fn_ctxt fcx, &hashmap[int,@ty.t] bindings, @ty.t expected,
534534
@ty.t actual) -> unify_result {
535535
// TODO: rewrite this using tuple pattern matching when available, to
536536
// avoid all this rightward drift and spikiness.
@@ -877,7 +877,7 @@ fn unify(&fn_ctxt fcx, @ty.t expected, @ty.t actual) -> unify_result {
877877

878878
// Requires that the two types unify, and prints an error message if they
879879
// don't. Returns the unified type.
880-
fn demand(&fn_ctxt fcx, &span sp, @ty.t expected, @ty.t actual) -> @ty.t {
880+
fn demand(&@fn_ctxt fcx, &span sp, @ty.t expected, @ty.t actual) -> @ty.t {
881881
alt (unify(fcx, expected, actual)) {
882882
case (ures_ok(?ty)) {
883883
ret ty;
@@ -897,7 +897,7 @@ fn demand(&fn_ctxt fcx, &span sp, @ty.t expected, @ty.t actual) -> @ty.t {
897897
}
898898

899899
// Returns true if the two types unify and false if they don't.
900-
fn are_compatible(&fn_ctxt fcx, @ty.t expected, @ty.t actual) -> bool {
900+
fn are_compatible(&@fn_ctxt fcx, @ty.t expected, @ty.t actual) -> bool {
901901
alt (unify(fcx, expected, actual)) {
902902
case (ures_ok(_)) { ret true; }
903903
case (ures_err(_, _, _)) { ret false; }
@@ -909,7 +909,7 @@ fn are_compatible(&fn_ctxt fcx, @ty.t expected, @ty.t actual) -> bool {
909909
//
910910
// TODO: enforce this via a predicate.
911911

912-
fn demand_pat(&fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
912+
fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
913913
auto p_1 = ast.pat_wild(ast.ann_none); // FIXME: typestate botch
914914

915915
alt (pat.node) {
@@ -970,7 +970,7 @@ fn demand_pat(&fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
970970
// TODO: propagate the types downward. This makes the typechecker quadratic,
971971
// but we can mitigate that if expected == actual == unified.
972972

973-
fn demand_expr(&fn_ctxt fcx, @ty.t expected, @ast.expr e) -> @ast.expr {
973+
fn demand_expr(&@fn_ctxt fcx, @ty.t expected, @ast.expr e) -> @ast.expr {
974974
// FIXME: botch to work around typestate bug in rustboot
975975
let vec[@ast.expr] v = vec();
976976
auto e_1 = ast.expr_vec(v, ast.ann_none);
@@ -1112,7 +1112,7 @@ fn demand_expr(&fn_ctxt fcx, @ty.t expected, @ast.expr e) -> @ast.expr {
11121112
}
11131113

11141114
// Type unification over typed blocks.
1115-
fn demand_block(&fn_ctxt fcx, @ty.t expected, &ast.block bloc) -> ast.block {
1115+
fn demand_block(&@fn_ctxt fcx, @ty.t expected, &ast.block bloc) -> ast.block {
11161116
alt (bloc.node.expr) {
11171117
case (some[@ast.expr](?e_0)) {
11181118
auto e_1 = demand_expr(fcx, expected, e_0);
@@ -1130,7 +1130,7 @@ fn demand_block(&fn_ctxt fcx, @ty.t expected, &ast.block bloc) -> ast.block {
11301130

11311131
// Writeback: the phase that writes inferred types back into the AST.
11321132

1133-
fn writeback_local(&fn_ctxt fcx, &span sp, @ast.local local)
1133+
fn writeback_local(&@fn_ctxt fcx, &span sp, @ast.local local)
11341134
-> @ast.decl {
11351135
if (!fcx.locals.contains_key(local.id)) {
11361136
fcx.ccx.sess.span_err(sp, "unable to determine type of local: "
@@ -1141,11 +1141,11 @@ fn writeback_local(&fn_ctxt fcx, &span sp, @ast.local local)
11411141
ret @fold.respan[ast.decl_](sp, ast.decl_local(local_wb));
11421142
}
11431143

1144-
fn writeback(&fn_ctxt fcx, &ast.block block) -> ast.block {
1145-
auto fld = fold.new_identity_fold[fn_ctxt]();
1144+
fn writeback(&@fn_ctxt fcx, &ast.block block) -> ast.block {
1145+
auto fld = fold.new_identity_fold[@fn_ctxt]();
11461146
auto f = writeback_local;
11471147
fld = @rec(fold_decl_local = f with *fld);
1148-
ret fold.fold_block[fn_ctxt](fcx, fld, block);
1148+
ret fold.fold_block[@fn_ctxt](fcx, fld, block);
11491149
}
11501150

11511151
// AST fragment checking
@@ -1165,7 +1165,7 @@ fn check_lit(@ast.lit lit) -> @ty.t {
11651165
ret plain_ty(sty);
11661166
}
11671167

1168-
fn check_pat(&fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
1168+
fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
11691169
auto new_pat;
11701170
alt (pat.node) {
11711171
case (ast.pat_wild(_)) {
@@ -1227,7 +1227,7 @@ fn check_pat(&fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
12271227
ret @fold.respan[ast.pat_](pat.span, new_pat);
12281228
}
12291229

1230-
fn check_expr(&fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
1230+
fn check_expr(&@fn_ctxt fcx, @ast.expr expr) -> @ast.expr {
12311231
alt (expr.node) {
12321232
case (ast.expr_lit(?lit, _)) {
12331233
auto ty = check_lit(lit);
@@ -1711,8 +1711,7 @@ fn next_ty_var(@crate_ctxt ccx) -> @ty.t {
17111711
ret t;
17121712
}
17131713

1714-
fn check_stmt(&fn_ctxt fcx, &@ast.stmt stmt)
1715-
-> @ast.stmt {
1714+
fn check_stmt(&@fn_ctxt fcx, &@ast.stmt stmt) -> @ast.stmt {
17161715
alt (stmt.node) {
17171716
case (ast.stmt_decl(?decl)) {
17181717
alt (decl.node) {
@@ -1800,7 +1799,7 @@ fn check_stmt(&fn_ctxt fcx, &@ast.stmt stmt)
18001799
fail;
18011800
}
18021801

1803-
fn check_block(&fn_ctxt fcx, &ast.block block) -> ast.block {
1802+
fn check_block(&@fn_ctxt fcx, &ast.block block) -> ast.block {
18041803
let vec[@ast.stmt] stmts = vec();
18051804
for (@ast.stmt s in block.node.stmts) {
18061805
append[@ast.stmt](stmts, check_stmt(fcx, s));
@@ -1824,9 +1823,9 @@ fn check_const(&@crate_ctxt ccx, &span sp, ast.ident ident, @ast.ty t,
18241823
// FIXME: this is kinda a kludge; we manufacture a fake "function context"
18251824
// for checking the initializer expression.
18261825
auto rty = ann_to_type(ann);
1827-
let fn_ctxt fcx = rec(ret_ty = rty,
1828-
locals = @common.new_def_hash[@ty.t](),
1829-
ccx = ccx);
1826+
let @fn_ctxt fcx = @rec(ret_ty = rty,
1827+
locals = @common.new_def_hash[@ty.t](),
1828+
ccx = ccx);
18301829
auto e_ = check_expr(fcx, e);
18311830
// FIXME: necessary? Correct sequence?
18321831
demand_expr(fcx, rty, e_);
@@ -1848,9 +1847,9 @@ fn check_fn(&@crate_ctxt ccx, ast.effect effect,
18481847
auto input_ty = ast_ty_to_ty_crate(ccx, arg.ty);
18491848
local_ty_table.insert(arg.id, input_ty);
18501849
}
1851-
let fn_ctxt fcx = rec(ret_ty = ast_ty_to_ty_crate(ccx, output),
1852-
locals = local_ty_table,
1853-
ccx = ccx);
1850+
let @fn_ctxt fcx = @rec(ret_ty = ast_ty_to_ty_crate(ccx, output),
1851+
locals = local_ty_table,
1852+
ccx = ccx);
18541853

18551854
// TODO: Make sure the type of the block agrees with the function type.
18561855
auto block_t = check_block(fcx, body);

0 commit comments

Comments
 (0)