Skip to content

Commit ff9c5db

Browse files
Tweak wording
1 parent 3dd638f commit ff9c5db

10 files changed

+40
-21
lines changed

compiler/rustc_hir_typeck/src/callee.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,15 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
247247
adjusted_ty,
248248
opt_input_type.as_ref().map(slice::from_ref),
249249
) {
250+
// Check for `self` receiver on the method, otherwise we can't use this as a `Fn*` trait.
251+
if !self.tcx.associated_item(ok.value.def_id).fn_has_self_parameter {
252+
self.tcx.sess.delay_span_bug(
253+
call_expr.span,
254+
"input to overloaded call fn is not a self receiver",
255+
);
256+
return None;
257+
}
258+
250259
let method = self.register_infer_ok_obligations(ok);
251260
let mut autoref = None;
252261
if borrow {
@@ -257,7 +266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
257266
// caused an error elsewhere.
258267
self.tcx
259268
.sess
260-
.delay_span_bug(call_expr.span, "input to call/call_mut is not a ref?");
269+
.delay_span_bug(call_expr.span, "input to call/call_mut is not a ref");
261270
return None;
262271
};
263272

@@ -271,6 +280,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
271280
target: method.sig.inputs()[0],
272281
});
273282
}
283+
274284
return Some((autoref, method));
275285
}
276286
}
@@ -823,7 +833,7 @@ impl<'a, 'tcx> DeferredCallResolution<'tcx> {
823833
);
824834
err.help(
825835
"make sure the `fn`/`fn_mut`/`fn_once` lang items are defined \
826-
and have associated `call`/`call_mut`/`call_once` functions",
836+
and have correctly defined `call`/`call_mut`/`call_once` methods",
827837
);
828838
err.emit();
829839
}

tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_item.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: failed to find an overloaded call trait for closure call
44
LL | a();
55
| ^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: failed to find an overloaded call trait for closure call
1010
--> $DIR/fn-fn_mut-call-ill-formed.rs:43:5
1111
|
1212
LL | b();
1313
| ^^^
1414
|
15-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
1616

1717
error: aborting due to 2 previous errors
1818

tests/ui/lang-items/fn-fn_mut-call-ill-formed.bad_sig.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: failed to find an overloaded call trait for closure call
44
LL | a();
55
| ^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: failed to find an overloaded call trait for closure call
1010
--> $DIR/fn-fn_mut-call-ill-formed.rs:43:5
1111
|
1212
LL | b();
1313
| ^^^
1414
|
15-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
1616

1717
error: aborting due to 2 previous errors
1818

tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_item.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: failed to find an overloaded call trait for closure call
44
LL | a();
55
| ^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: failed to find an overloaded call trait for closure call
1010
--> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
1111
|
1212
LL | b();
1313
| ^^^
1414
|
15-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
1616

1717
error: aborting due to 2 previous errors
1818

tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_bad_sig.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: failed to find an overloaded call trait for closure call
44
LL | a();
55
| ^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: failed to find an overloaded call trait for closure call
1010
--> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
1111
|
1212
LL | b();
1313
| ^^^
1414
|
15-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
1616

1717
error: aborting due to 2 previous errors
1818

tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_item.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: failed to find an overloaded call trait for closure call
44
LL | a();
55
| ^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: failed to find an overloaded call trait for closure call
1010
--> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
1111
|
1212
LL | b();
1313
| ^^^
1414
|
15-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
1616

1717
error: aborting due to 2 previous errors
1818

tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_mut_bad_sig.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: failed to find an overloaded call trait for closure call
44
LL | a();
55
| ^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: failed to find an overloaded call trait for closure call
1010
--> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
1111
|
1212
LL | b();
1313
| ^^^
1414
|
15-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
1616

1717
error: aborting due to 2 previous errors
1818

tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_item.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ error: failed to find an overloaded call trait for closure call
44
LL | a();
55
| ^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: failed to find an overloaded call trait for closure call
1010
--> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
1111
|
1212
LL | b();
1313
| ^^^
1414
|
15-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
1616

1717
error: aborting due to 2 previous errors
1818

tests/ui/lang-items/fn-fn_mut-call-ill-formed.fn_once_bad_sig.stderr

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
error[E0308]: mismatched types
1+
error: failed to find an overloaded call trait for closure call
2+
--> $DIR/fn-fn_mut-call-ill-formed.rs:42:5
3+
|
4+
LL | a();
5+
| ^^^
6+
|
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
8+
9+
error: failed to find an overloaded call trait for closure call
210
--> $DIR/fn-fn_mut-call-ill-formed.rs:47:5
311
|
412
LL | b();
5-
| ^^^ expected `i32`, found `()`
13+
| ^^^
14+
|
15+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
616

7-
error: aborting due to previous error
17+
error: aborting due to 2 previous errors
818

9-
For more information about this error, try `rustc --explain E0308`.

tests/ui/lang-items/issue-86238.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error: failed to find an overloaded call trait for closure call
44
LL | one()
55
| ^^^^^
66
|
7-
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have associated `call`/`call_mut`/`call_once` functions
7+
= help: make sure the `fn`/`fn_mut`/`fn_once` lang items are defined and have correctly defined `call`/`call_mut`/`call_once` methods
88

99
error: aborting due to previous error
1010

0 commit comments

Comments
 (0)