Skip to content

Commit 2530ce9

Browse files
committed
Add comment.
1 parent 2f42a18 commit 2530ce9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc_typeck/check/callee.rs

+7
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
144144
_ => {}
145145
}
146146

147+
// Now, we look for the implementation of a Fn trait on the object's type.
148+
// We first do it with the explicit instruction to look for an impl of
149+
// `Fn<Tuple>`, with the tuple `Tuple` having an arity corresponding
150+
// to the number of call parameters.
151+
// If that fails (or_else branch), we try again without specifying the
152+
// shape of the tuple (hence the None). This allows to detect an Fn trait
153+
// is implemented, and use this information for diagnostic.
147154
self.try_overloaded_call_traits(call_expr, adjusted_ty, Some(arg_exprs))
148155
.or_else(|| self.try_overloaded_call_traits(call_expr, adjusted_ty, None))
149156
.map(|(autoref, method)| {

0 commit comments

Comments
 (0)