-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
FnOnce doesn't seem to support type-based dispatch (as Add, etc. do) #45510
Copy link
Copy link
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-langRelevant to the language teamRelevant to the language team
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-langRelevant to the language teamRelevant to the language team
Type
Fields
Give feedbackNo fields configured for issues without a type.
UPDATE: Mentoring instructions below.
Here's a minimal example program showing the issue:
This works perfectly if you comment out either the
IshmaelorMaybeimplementations, and the corresponding call. I've wanted this behavior at various times - if nothing else, it'd be useful for binding to certain parts of C++ - and at least in theory it's the same exact mechanismAdd::adduses.In addition, the error message is (to
steallovingly borrow a term from the Perl 6 community) "less than awesome" - it informs the usererror[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unitwhen it clearly is (as it succeeds in the single-impl case).It also claims
error[E0619]: the type of this value must be known in this context, but only for the argument of the first call - reversing the order also exchanges the subject of the error message.Should this be supported? If so, what needs done? If not, how can we make the error messages more helpful? Not supporting it now and adding support later is forwards-compatible, but at very least the error message should probably be improved before stabilization (cc #29625)
EDIT: Ah, seems this may be covered by #18952