@@ -50,17 +50,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
50
50
let id = expr. hir_id ;
51
51
match expr. node {
52
52
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)
62
54
}
63
-
64
55
ExprKind :: Lit ( ref lit) => {
65
56
self . check_lit ( & lit, expected)
66
57
}
@@ -703,4 +694,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
703
694
}
704
695
}
705
696
}
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
+ }
706
709
}
0 commit comments