about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-06-15 03:01:05 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-06-15 04:01:39 +0200
commit819c4f2f0890baea055d80d3f68a776328d1f5fb (patch)
tree25fe704c0d7fc2a6e6b9a4ef9bb94cfd57eec43a
parent18edf3ed08b5d7827cdd440801d70d1d5703d8c8 (diff)
downloadrust-819c4f2f0890baea055d80d3f68a776328d1f5fb.tar.gz
rust-819c4f2f0890baea055d80d3f68a776328d1f5fb.zip
typeck/expr.rs: move some check_return_expr here.
-rw-r--r--src/librustc_typeck/check/expr.rs17
-rw-r--r--src/librustc_typeck/check/mod.rs17
2 files changed, 17 insertions, 17 deletions
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs
index da90988814b..7aa47a1a3a1 100644
--- a/src/librustc_typeck/check/expr.rs
+++ b/src/librustc_typeck/check/expr.rs
@@ -633,6 +633,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         self.tcx.types.never
     }
 
+    pub(super) fn check_return_expr(&self, return_expr: &'tcx hir::Expr) {
+        let ret_coercion =
+            self.ret_coercion
+                .as_ref()
+                .unwrap_or_else(|| span_bug!(return_expr.span,
+                                             "check_return_expr called outside fn body"));
+
+        let ret_ty = ret_coercion.borrow().expected_ty();
+        let return_expr_ty = self.check_expr_with_hint(return_expr, ret_ty.clone());
+        ret_coercion.borrow_mut()
+                    .coerce(self,
+                            &self.cause(return_expr.span,
+                                        ObligationCauseCode::ReturnType(return_expr.hir_id)),
+                            return_expr,
+                            return_expr_ty);
+    }
+
     /// Type check assignment expression `expr` of form `lhs = rhs`.
     /// The expected type is `()` and is passsed to the function for the purposes of diagnostics.
     fn check_expr_assign(
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index f5905f9a497..0cc86744cc9 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3312,23 +3312,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                                          expected)
     }
 
-    fn check_return_expr(&self, return_expr: &'tcx hir::Expr) {
-        let ret_coercion =
-            self.ret_coercion
-                .as_ref()
-                .unwrap_or_else(|| span_bug!(return_expr.span,
-                                             "check_return_expr called outside fn body"));
-
-        let ret_ty = ret_coercion.borrow().expected_ty();
-        let return_expr_ty = self.check_expr_with_hint(return_expr, ret_ty.clone());
-        ret_coercion.borrow_mut()
-                    .coerce(self,
-                            &self.cause(return_expr.span,
-                                        ObligationCauseCode::ReturnType(return_expr.hir_id)),
-                            return_expr,
-                            return_expr_ty);
-    }
-
     // Check field access expressions
     fn check_field(
         &self,