Skip to content

Commit 7227a38

Browse files
committed
typeck/expr.rs: extract out check_expr_box.
1 parent 6cf4b3a commit 7227a38

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/librustc_typeck/check/expr.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
5050
let id = expr.hir_id;
5151
match expr.node {
5252
ExprKind::Box(ref subexpr) => {
53-
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| {
54-
match ty.sty {
55-
ty::Adt(def, _) if def.is_box()
56-
=> Expectation::rvalue_hint(self, ty.boxed_ty()),
57-
_ => NoExpectation
58-
}
59-
});
60-
let referent_ty = self.check_expr_with_expectation(subexpr, expected_inner);
61-
tcx.mk_box(referent_ty)
53+
self.check_expr_box(subexpr, expected)
6254
}
63-
6455
ExprKind::Lit(ref lit) => {
6556
self.check_lit(&lit, expected)
6657
}
@@ -703,4 +694,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
703694
}
704695
}
705696
}
697+
698+
fn check_expr_box(&self, expr: &'tcx hir::Expr, expected: Expectation<'tcx>) -> Ty<'tcx> {
699+
let expected_inner = expected.to_option(self).map_or(NoExpectation, |ty| {
700+
match ty.sty {
701+
ty::Adt(def, _) if def.is_box()
702+
=> Expectation::rvalue_hint(self, ty.boxed_ty()),
703+
_ => NoExpectation
704+
}
705+
});
706+
let referent_ty = self.check_expr_with_expectation(expr, expected_inner);
707+
self.tcx.mk_box(referent_ty)
708+
}
706709
}

0 commit comments

Comments
 (0)