]> git.lizzy.rs Git - rust.git/commitdiff
Fix `has_no_input_arg` function has self check
authorRustin-Liu <rustin.liu@gmail.com>
Sat, 18 Apr 2020 03:32:39 +0000 (11:32 +0800)
committerRustin-Liu <rustin.liu@gmail.com>
Sun, 19 Apr 2020 05:38:52 +0000 (13:38 +0800)
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>
src/librustc_typeck/check/demand.rs

index be45ada866f32ec2d751dce0f2cf227895112faa..5782243cbbd80424aa675e1a59d9118a9e31890d 100644 (file)
@@ -222,7 +222,7 @@ pub fn get_conversion_methods(
         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 @@ pub fn get_conversion_methods(
         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,
         }
     }