Skip to content

Commit e80d303

Browse files
authored
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 #70643 (comment).
2 parents 2f06ac0 + 7c28dfe commit e80d303

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)