Skip to content

Commit f0dfcc2

Browse files
committed
---
yaml --- r: 6632 b: refs/heads/master c: 8c966b7 h: refs/heads/master v: v3
1 parent 3b69b36 commit f0dfcc2

File tree

2 files changed

+8
-28
lines changed

2 files changed

+8
-28
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: a7c6cb73858a2659651bc0ff9dfd1cdb72239d32
2+
refs/heads/master: 8c966b7b18a5529c33dd9766460880bd681ab102

trunk/src/comp/middle/typeck.rs

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ tag obj_info {
3535
type crate_ctxt = {mutable obj_infos: [obj_info], tcx: ty::ctxt};
3636

3737
type fn_ctxt =
38-
// var_bindings, locals, local_names, and next_var_id are shared
38+
// var_bindings, locals and next_var_id are shared
3939
// with any nested functions that capture the environment
4040
// (and with any functions whose environment is being captured).
4141
{ret_ty: ty::t,
4242
purity: ast::purity,
4343
proto: ast::proto,
4444
var_bindings: @ty::unify::var_bindings,
4545
locals: hashmap<ast::node_id, int>,
46-
local_names: hashmap<ast::node_id, ast::ident>,
4746
next_var_id: @mutable int,
4847
mutable fixups: [ast::node_id],
4948
ccx: @crate_ctxt};
@@ -72,13 +71,6 @@ fn lookup_def(fcx: @fn_ctxt, sp: span, id: ast::node_id) -> ast::def {
7271
}
7372
}
7473

75-
fn ident_for_local(loc: @ast::local) -> ast::ident {
76-
ret alt loc.node.pat.node {
77-
ast::pat_bind(name) { name }
78-
_ { "local" }
79-
}; // FIXME DESTR
80-
}
81-
8274
// Returns the type parameter count and the type for the given definition.
8375
fn ty_param_kinds_and_ty_for_def(fcx: @fn_ctxt, sp: span, defn: ast::def) ->
8476
ty_param_kinds_and_ty {
@@ -1117,36 +1109,31 @@ mod writeback {
11171109
type gather_result =
11181110
{var_bindings: @ty::unify::var_bindings,
11191111
locals: hashmap<ast::node_id, int>,
1120-
local_names: hashmap<ast::node_id, ast::ident>,
11211112
next_var_id: @mutable int};
11221113

11231114
// Used only as a helper for check_fn.
11241115
fn gather_locals(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id,
11251116
old_fcx: option::t<@fn_ctxt>) -> gather_result {
1126-
let {vb: vb, locals: locals, local_names: local_names, nvi: nvi} =
1117+
let {vb: vb, locals: locals, nvi: nvi} =
11271118
alt old_fcx {
11281119
none. {
11291120
{vb: ty::unify::mk_var_bindings(),
11301121
locals: new_int_hash::<int>(),
1131-
local_names: new_int_hash::<ast::ident>(),
11321122
nvi: @mutable 0}
11331123
}
11341124
some(fcx) {
11351125
{vb: fcx.var_bindings,
11361126
locals: fcx.locals,
1137-
local_names: fcx.local_names,
11381127
nvi: fcx.next_var_id}
11391128
}
11401129
};
11411130
let tcx = ccx.tcx;
11421131

11431132
let next_var_id = lambda () -> int { let rv = *nvi; *nvi += 1; ret rv; };
11441133
let assign =
1145-
lambda (nid: ast::node_id, ident: ast::ident,
1146-
ty_opt: option::t<ty::t>) {
1134+
lambda (nid: ast::node_id, ty_opt: option::t<ty::t>) {
11471135
let var_id = next_var_id();
11481136
locals.insert(nid, var_id);
1149-
local_names.insert(nid, ident);
11501137
alt ty_opt {
11511138
none. {/* nothing to do */ }
11521139
some(typ) {
@@ -1168,30 +1155,30 @@ fn gather_locals(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id,
11681155
}
11691156
for f: ast::obj_field in obj_fields {
11701157
let field_ty = ty::node_id_to_type(ccx.tcx, f.id);
1171-
assign(f.id, f.ident, some(field_ty));
1158+
assign(f.id, some(field_ty));
11721159
}
11731160

11741161
// Add formal parameters.
11751162
let args = ty::ty_fn_args(ccx.tcx, ty::node_id_to_type(ccx.tcx, id));
11761163
let i = 0u;
11771164
for arg: ty::arg in args {
1178-
assign(f.decl.inputs[i].id, f.decl.inputs[i].ident, some(arg.ty));
1165+
assign(f.decl.inputs[i].id, some(arg.ty));
11791166
i += 1u;
11801167
}
11811168

11821169
// Add explicitly-declared locals.
11831170
let visit_local =
11841171
lambda (local: @ast::local, &&e: (), v: visit::vt<()>) {
11851172
let local_ty = ast_ty_to_ty_crate_infer(ccx, local.node.ty);
1186-
assign(local.node.id, ident_for_local(local), local_ty);
1173+
assign(local.node.id, local_ty);
11871174
visit::visit_local(local, e, v);
11881175
};
11891176

11901177
// Add pattern bindings.
11911178
let visit_pat =
11921179
lambda (p: @ast::pat, &&e: (), v: visit::vt<()>) {
11931180
alt p.node {
1194-
ast::pat_bind(ident) { assign(p.id, ident, none); }
1181+
ast::pat_bind(_) { assign(p.id, none); }
11951182
_ {/* no-op */ }
11961183
}
11971184
visit::visit_pat(p, e, v);
@@ -1214,7 +1201,6 @@ fn gather_locals(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id,
12141201
visit::visit_block(f.body, (), visit::mk_vt(visit));
12151202
ret {var_bindings: vb,
12161203
locals: locals,
1217-
local_names: local_names,
12181204
next_var_id: nvi};
12191205
}
12201206

@@ -2409,10 +2395,6 @@ fn check_decl_local(fcx: @fn_ctxt, local: @ast::local) -> bool {
24092395
let bot = false;
24102396

24112397
alt fcx.locals.find(local.node.id) {
2412-
none. {
2413-
fcx.ccx.tcx.sess.bug("check_decl_local: local id not found " +
2414-
ident_for_local(local));
2415-
}
24162398
some(i) {
24172399
let t = ty::mk_var(fcx.ccx.tcx, i);
24182400
write::ty_only_fixup(fcx, local.node.id, t);
@@ -2498,7 +2480,6 @@ fn check_const(ccx: @crate_ctxt, _sp: span, e: @ast::expr, id: ast::node_id) {
24982480
proto: ast::proto_shared(ast::sugar_normal),
24992481
var_bindings: ty::unify::mk_var_bindings(),
25002482
locals: new_int_hash::<int>(),
2501-
local_names: new_int_hash::<ast::ident>(),
25022483
next_var_id: @mutable 0,
25032484
mutable fixups: fixups,
25042485
ccx: ccx};
@@ -2640,7 +2621,6 @@ fn check_fn(ccx: @crate_ctxt, f: ast::_fn, id: ast::node_id,
26402621
proto: f.proto,
26412622
var_bindings: gather_result.var_bindings,
26422623
locals: gather_result.locals,
2643-
local_names: gather_result.local_names,
26442624
next_var_id: gather_result.next_var_id,
26452625
mutable fixups: fixups,
26462626
ccx: ccx};

0 commit comments

Comments
 (0)