@@ -1507,12 +1507,12 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1507
1507
// resolution is not possible (e.g., no constraints yet present), just
1508
1508
// returns `none`.
1509
1509
fn unpack_expected < O : Copy > ( fcx : @fn_ctxt , expected : Option < ty:: t > ,
1510
- unpack : fn ( ty:: sty ) -> Option < O > )
1510
+ unpack : fn ( & ty:: sty ) -> Option < O > )
1511
1511
-> Option < O > {
1512
1512
match expected {
1513
1513
Some ( t) => {
1514
1514
match resolve_type ( fcx. infcx ( ) , t, force_tvar) {
1515
- Ok ( t) => unpack ( ty:: get ( t) . sty ) ,
1515
+ Ok ( t) => unpack ( & ty:: get ( t) . sty ) ,
1516
1516
_ => None
1517
1517
}
1518
1518
}
@@ -1537,7 +1537,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1537
1537
// to impure and block. Note that we only will use those for
1538
1538
// block syntax lambdas; that is, lambdas without explicit
1539
1539
// protos.
1540
- let expected_sty = unpack_expected ( fcx, expected, |x| Some ( x) ) ;
1540
+ let expected_sty = unpack_expected ( fcx, expected, |x| Some ( copy * x) ) ;
1541
1541
let ( expected_tys,
1542
1542
expected_purity,
1543
1543
expected_proto,
@@ -1969,8 +1969,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
1969
1969
ast::expr_unary(unop, oprnd) => {
1970
1970
let exp_inner = do unpack_expected(fcx, expected) |sty| {
1971
1971
match unop {
1972
- ast::box(_) | ast::uniq(_) => match sty {
1973
- ty::ty_box(mt) | ty::ty_uniq(mt) => Some(mt.ty),
1972
+ ast::box(_) | ast::uniq(_) => match * sty {
1973
+ ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => Some(mt.ty),
1974
1974
_ => None
1975
1975
},
1976
1976
ast::not | ast::neg => expected,
@@ -2050,8 +2050,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
2050
2050
fcx.write_ty(id, oprnd_t);
2051
2051
}
2052
2052
ast::expr_addr_of(mutbl, oprnd) => {
2053
- bot = check_expr(fcx, oprnd, unpack_expected(fcx, expected, |ty |
2054
- match ty { ty::ty_rptr(_, mt) => Some(mt.ty), _ => None }
2053
+ bot = check_expr(fcx, oprnd, unpack_expected(fcx, expected, |sty |
2054
+ match *sty { ty::ty_rptr(_, ref mt) => Some(mt.ty), _ => None }
2055
2055
));
2056
2056
2057
2057
// Note: at this point, we cannot say what the best lifetime
@@ -2177,7 +2177,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
2177
2177
// 1. a closure that returns a bool is expected
2178
2178
// 2. the closure that was given returns unit
2179
2179
let mut err_happened = false;
2180
- let expected_sty = unpack_expected(fcx, expected, |x| Some(x));
2180
+ let expected_sty = unpack_expected(fcx, expected, |x| Some(copy * x));
2181
2181
let inner_ty = match expected_sty {
2182
2182
Some(ty::ty_fn(ref fty)) => {
2183
2183
match fcx.mk_subty(false, expr.span,
@@ -2240,7 +2240,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
2240
2240
}
2241
2241
}
2242
2242
ast:: expr_do_body ( b) => {
2243
- let expected_sty = unpack_expected ( fcx, expected, |x| Some ( x) ) ;
2243
+ let expected_sty = unpack_expected ( fcx, expected, |x| Some ( copy * x) ) ;
2244
2244
let inner_ty = match expected_sty {
2245
2245
Some ( ty:: ty_fn( ref fty) ) => {
2246
2246
ty:: mk_fn ( tcx, ( /*bad*/ copy * fty) )
@@ -2349,11 +2349,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
2349
2349
}
2350
2350
ast:: expr_tup ( elts) => {
2351
2351
let flds = unpack_expected ( fcx, expected, |sty| {
2352
- // XXX: Beware! If you remove `copy` below, the borrow checker
2353
- // will NOT complain, but you will get a segfault at runtime! This
2354
- // is because the mode computation is currently unaware of
2355
- // argument modes.
2356
- match copy sty { ty:: ty_tup( flds) => Some ( flds) , _ => None }
2352
+ match * sty { ty:: ty_tup( ref flds) => Some ( copy * flds) , _ => None }
2357
2353
} ) ;
2358
2354
let elt_ts = do elts. mapi |i, e| {
2359
2355
check_expr ( fcx, * e, flds. map ( |fs| fs[ i] ) ) ;
@@ -2368,12 +2364,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
2368
2364
Some ( fcx. expr_ty ( base. get ( ) ) )
2369
2365
} else { expected } ;
2370
2366
let flds = unpack_expected ( fcx, expected, |sty|
2371
- // XXX: Beware! If you remove `copy` below, the borrow checker
2372
- // will NOT complain, but you will get a segfault at runtime! This
2373
- // is because the mode computation is currently unaware of
2374
- // argument modes.
2375
- match copy sty {
2376
- ty:: ty_rec( flds) => Some ( flds) ,
2367
+ match * sty {
2368
+ ty:: ty_rec( ref flds) => Some ( copy * flds) ,
2377
2369
_ => None
2378
2370
}
2379
2371
) ;
0 commit comments