about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-20 18:07:07 +0200
committerGitHub <noreply@github.com>2020-04-20 18:07:07 +0200
commite80d30347ab9dc2e4f73a9f3c8cc3bf09914a597 (patch)
tree5ac2cf2ec79073dc9695011eb6adfbc4a83cfa90
parent2f06ac08e923a146134199cdb72c08b85a800203 (diff)
parent7c28dfe113649663c1871bbbe9ad5d4f227ecf45 (diff)
downloadrust-e80d30347ab9dc2e4f73a9f3c8cc3bf09914a597.tar.gz
rust-e80d30347ab9dc2e4f73a9f3c8cc3bf09914a597.zip
Rollup merge of #71270 - Rustin-Liu:rustin-patch-has-self, r=estebank
Fix `has_no_input_arg` check and rename it to `has_only_self_parameter`

Signed-off-by: Rustin-Liu <rustin.liu@gmail.com>

Fixes https://github.com/rust-lang/rust/pull/70643#discussion_r401571789.
-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 6f142f77696..7db376b20aa 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,
         }
     }