Skip to content

Commit 9c0c0af

Browse files
committed
rustc: Fix inference for auto slots (forgot to stage changes before)
1 parent a599d80 commit 9c0c0af

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/comp/middle/typeck.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,9 @@ fn collect_item_types(session.session sess, @ast.crate crate)
924924
fn unify(&@fn_ctxt fcx, @ty.t expected, @ty.t actual) -> ty.unify_result {
925925
obj unify_handler(@fn_ctxt fcx) {
926926
fn resolve_local(ast.def_id id) -> @ty.t {
927-
check (fcx.locals.contains_key(id));
927+
if (!fcx.locals.contains_key(id)) {
928+
ret next_ty_var(fcx.ccx);
929+
}
928930
ret fcx.locals.get(id);
929931
}
930932
fn record_local(ast.def_id id, @ty.t t) {
@@ -2377,20 +2379,17 @@ fn check_decl_local(&@fn_ctxt fcx, &@ast.decl decl) -> @ast.decl {
23772379
alt (decl.node) {
23782380
case (ast.decl_local(?local)) {
23792381

2380-
auto local_ty;
23812382
alt (local.ty) {
23822383
case (none[@ast.ty]) {
2383-
// Auto slot. Assign a ty_var.
2384-
local_ty = next_ty_var(fcx.ccx);
2384+
// Auto slot. Do nothing for now.
23852385
}
23862386

23872387
case (some[@ast.ty](?ast_ty)) {
2388-
local_ty = ast_ty_to_ty_crate(fcx.ccx, ast_ty);
2388+
auto local_ty = ast_ty_to_ty_crate(fcx.ccx, ast_ty);
2389+
fcx.locals.insert(local.id, local_ty);
23892390
}
23902391
}
2391-
fcx.locals.insert(local.id, local_ty);
23922392

2393-
auto rhs_ty = local_ty;
23942393
auto init = local.init;
23952394
alt (local.init) {
23962395
case (some[@ast.expr](?expr)) {

0 commit comments

Comments
 (0)