Skip to content

Commit 7c28dfe

Browse files
committed
Fix has_no_input_arg function has self check
Signed-off-by: Rustin-Liu <[email protected]> rename has_no_input_arg to has_only_self_parameter Signed-off-by: Rustin-Liu <[email protected]>
1 parent 8001b96 commit 7c28dfe

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/librustc_typeck/check/demand.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
222222
let mut methods =
223223
self.probe_for_return_type(span, probe::Mode::MethodCall, expected, checked_ty, hir_id);
224224
methods.retain(|m| {
225-
self.has_no_input_arg(m)
225+
self.has_only_self_parameter(m)
226226
&& self
227227
.tcx
228228
.get_attrs(m.def_id)
@@ -243,10 +243,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
243243
methods
244244
}
245245

246-
// This function checks if the method isn't static and takes other arguments than `self`.
247-
fn has_no_input_arg(&self, method: &AssocItem) -> bool {
246+
/// This function checks whether the method is not static and does not accept other parameters than `self`.
247+
fn has_only_self_parameter(&self, method: &AssocItem) -> bool {
248248
match method.kind {
249-
ty::AssocKind::Fn => self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1,
249+
ty::AssocKind::Fn => {
250+
method.fn_has_self_parameter
251+
&& self.tcx.fn_sig(method.def_id).inputs().skip_binder().len() == 1
252+
}
250253
_ => false,
251254
}
252255
}

0 commit comments

Comments
 (0)