about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-06-15 03:11:36 +0200
committerMazdak Farrokhzad <twingoow@gmail.com>2019-06-15 04:01:39 +0200
commit5ee36b7ecafc873ae15c4a4aa74f8293103b14c9 (patch)
treecabee40a35b7226ee1415558e8f412a161423c10
parent819c4f2f0890baea055d80d3f68a776328d1f5fb (diff)
downloadrust-5ee36b7ecafc873ae15c4a4aa74f8293103b14c9.tar.gz
rust-5ee36b7ecafc873ae15c4a4aa74f8293103b14c9.zip
typeck/expr.rs: move check_method_call here.
-rw-r--r--src/librustc_typeck/check/expr.rs51
-rw-r--r--src/librustc_typeck/check/mod.rs46
2 files changed, 50 insertions, 47 deletions
diff --git a/src/librustc_typeck/check/expr.rs b/src/librustc_typeck/check/expr.rs
index 7aa47a1a3a1..b133526054f 100644
--- a/src/librustc_typeck/check/expr.rs
+++ b/src/librustc_typeck/check/expr.rs
@@ -11,13 +11,16 @@ use crate::check::Expectation::{self, NoExpectation, ExpectHasType, ExpectCastab
 use crate::check::fatally_break_rust;
 use crate::check::report_unexpected_variant_res;
 use crate::check::Needs;
+use crate::check::TupleArgumentsFlag::DontTupleArguments;
+use crate::check::method::SelfSource;
 use crate::middle::lang_items;
 use crate::util::common::ErrorReported;
 
 use errors::Applicability;
 use syntax::ast;
 use syntax::ptr::P;
-use syntax::symbol::sym;
+use syntax::symbol::{kw, sym};
+use syntax::source_map::Span;
 use rustc::hir;
 use rustc::hir::{ExprKind, QPath};
 use rustc::hir::def::{CtorKind, Res, DefKind};
@@ -772,6 +775,52 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         ctxt.coerce.map(|c| c.complete(self)).unwrap_or_else(|| self.tcx.mk_unit())
     }
 
+    /// Checks a method call.
+    fn check_method_call(
+        &self,
+        expr: &'tcx hir::Expr,
+        segment: &hir::PathSegment,
+        span: Span,
+        args: &'tcx [hir::Expr],
+        expected: Expectation<'tcx>,
+        needs: Needs,
+    ) -> Ty<'tcx> {
+        let rcvr = &args[0];
+        let rcvr_t = self.check_expr_with_needs(&rcvr, needs);
+        // no need to check for bot/err -- callee does that
+        let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t);
+
+        let method = match self.lookup_method(rcvr_t,
+                                              segment,
+                                              span,
+                                              expr,
+                                              rcvr) {
+            Ok(method) => {
+                self.write_method_call(expr.hir_id, method);
+                Ok(method)
+            }
+            Err(error) => {
+                if segment.ident.name != kw::Invalid {
+                    self.report_method_error(span,
+                                             rcvr_t,
+                                             segment.ident,
+                                             SelfSource::MethodCall(rcvr),
+                                             error,
+                                             Some(args));
+                }
+                Err(())
+            }
+        };
+
+        // Call the generic checker.
+        self.check_method_argument_types(span,
+                                         expr.span,
+                                         method,
+                                         &args[1..],
+                                         DontTupleArguments,
+                                         expected)
+    }
+
     fn check_expr_cast(
         &self,
         e: &'tcx hir::Expr,
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index 0cc86744cc9..ae894a11452 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -3266,52 +3266,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         expect_args
     }
 
-    // Checks a method call.
-    fn check_method_call(
-        &self,
-        expr: &'tcx hir::Expr,
-        segment: &hir::PathSegment,
-        span: Span,
-        args: &'tcx [hir::Expr],
-        expected: Expectation<'tcx>,
-        needs: Needs,
-    ) -> Ty<'tcx> {
-        let rcvr = &args[0];
-        let rcvr_t = self.check_expr_with_needs(&rcvr, needs);
-        // no need to check for bot/err -- callee does that
-        let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t);
-
-        let method = match self.lookup_method(rcvr_t,
-                                              segment,
-                                              span,
-                                              expr,
-                                              rcvr) {
-            Ok(method) => {
-                self.write_method_call(expr.hir_id, method);
-                Ok(method)
-            }
-            Err(error) => {
-                if segment.ident.name != kw::Invalid {
-                    self.report_method_error(span,
-                                             rcvr_t,
-                                             segment.ident,
-                                             SelfSource::MethodCall(rcvr),
-                                             error,
-                                             Some(args));
-                }
-                Err(())
-            }
-        };
-
-        // Call the generic checker.
-        self.check_method_argument_types(span,
-                                         expr.span,
-                                         method,
-                                         &args[1..],
-                                         DontTupleArguments,
-                                         expected)
-    }
-
     // Check field access expressions
     fn check_field(
         &self,