about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRustin-Liu <rustin.liu@gmail.com>2020-04-18 11:32:39 +0800
committerRustin-Liu <rustin.liu@gmail.com>2020-04-19 13:38:52 +0800
commit7c28dfe113649663c1871bbbe9ad5d4f227ecf45 (patch)
tree6e1d02205d83b031012d8e3652cd2e0c1a392fee
parent8001b96f48d2c9cd646acd2d16f4e06078f258e1 (diff)
downloadrust-7c28dfe113649663c1871bbbe9ad5d4f227ecf45.tar.gz
rust-7c28dfe113649663c1871bbbe9ad5d4f227ecf45.zip
Fix `has_no_input_arg` function has self check
Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

rename has_no_input_arg to has_only_self_parameter

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>
-rw-r--r--src/librustc_typeck/check/demand.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs
index be45ada866f..5782243cbbd 100644
--- a/src/librustc_typeck/check/demand.rs
+++ b/src/librustc_typeck/check/demand.rs
@@ -222,7 +222,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         let mut methods =
             self.probe_for_return_type(span, probe::Mode::MethodCall, expected, checked_ty, hir_id);
         methods.retain(|m| {
-            self.has_no_input_arg(m)
+            self.has_only_self_parameter(m)
                 && self
                     .tcx
                     .get_attrs(m.def_id)
@@ -243,10 +243,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
         methods
     }
 
-    // This function checks if the method isn't static and takes other arguments than `self`.
-    fn has_no_input_arg(&self, method: &AssocItem) -> bool {
+    /// This function checks whether the method is not static and does not accept other parameters than `self`.
+    fn has_only_self_parameter(&self, method: &AssocItem) -> bool {
         match method.kind {
-            ty::AssocKind::Fn => self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1,
+            ty::AssocKind::Fn => {
+                method.fn_has_self_parameter
+                    && self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1
+            }
             _ => false,
         }
     }