Skip to content

Commit 0693a5b

Browse files
committed
Propagate expected type more widely so that we can rewrite the
issue-14039 test in a more natural way. Previously the "type we will cast to" was hidden unless it was an integer.
1 parent f197ce7 commit 0693a5b

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/librustc/middle/typeck/check/mod.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,13 +1382,7 @@ fn check_cast(fcx: &FnCtxt,
13821382
let t_1 = fcx.to_ty(t);
13831383
let t_1 = structurally_resolved_type(fcx, span, t_1);
13841384

1385-
if ty::type_is_scalar(t_1) {
1386-
// Supply the type as a hint so as to influence integer
1387-
// literals and other things that might care.
1388-
check_expr_with_expectation(fcx, e, ExpectCastableToType(t_1))
1389-
} else {
1390-
check_expr(fcx, e)
1391-
}
1385+
check_expr_with_expectation(fcx, e, ExpectCastableToType(t_1));
13921386

13931387
let t_e = fcx.expr_ty(e);
13941388

src/test/run-pass/issue-14039.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
fn foo<'a>() {
1414
if true {
1515
// in this branch, the lifetime is bound
16-
(box move|&mut: _: &mut ()| {}) as Box<FnMut(&mut ())>
16+
(box move|_| {}) as Box<FnMut(&mut ())>
1717
} else {
1818
// in this branch, the lifetime is free
19-
(box move|&mut: _: &mut ()| {}) as Box<FnMut(&'a mut ())>
19+
(box move|_| {}) as Box<FnMut(&'a mut ())>
2020
};
2121
}
2222

0 commit comments

Comments
 (0)