-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Error when casting a function is not informative #28959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is because no cast rule is legal. |
Still an unhelpful diagnostic that should be better. |
I don't really think it would be improved by "expected &-pointer, found *-pointer" (the issue is that an fn item does not necessarily have the same representation as an fn pointer, which makes the |
It may be desirable then to include an error for this particular case indicating that there is no valid version of the cast. |
It'd also be nice if there was some treatment of "functions are function items until you explicitly cast them to function pointer types" in the docs. |
@aidanhs: Hmm... that's a good point. I don't know that the distinction is made in the current version of the book. Is this something that would be worthwhile to include in the new version? cc: @steveklabnik |
For anyone who stumbles across this issue and wants to actually know how to cast functions (particularly extern ones), see #20178 for a hint until the docs/error message is updated. |
Triage: the error message is fundamentally the same here, just with the new format:
|
yields
This error tells me nothing about why it's invalid, and there's no extended explanation.
The text was updated successfully, but these errors were encountered: