You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Printed function definition types can be confusing #69232
An option would be to move the function name after the fn instead of after the signature, but doubt that would be enough. Best bet would be to add extra wording to the message about this being a specific function and expecting a function pointer, but the wording of those two is too close and lends itself to the same confusion we have now. Because of that, I think we should add a note explaining the nuance for these cases.
error[E0617]: can't pass `{individual function type for libc::unix::fread}` to variadic function
--> hg_connect.rs:844:62
|
844 | curl_easy_setopt(curl, CURLOPT_READFUNCTION, libc::fread);
| ^^^^^^^^^^^
|
help: cast the value to a function pointer:
|
844 | curl_easy_setopt(curl, CURLOPT_READFUNCTION, libc::fread as unsafe extern "C" fn(*mut core::ffi::c_void, usize, usize, *mut libc::unix::FILE) -> usize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I'd argue that confusion comes from seeing the "same" function signature so many times, so it's vital to distinguish between the individual function type vs the function pointer type as much (and as obviously) as possible.
changed the title [-]Error message for E0617 is confusing when functions are involved[/-][+]Printing function definition types can be confusing[/+]on Jan 21, 2024
Activity
jonas-schievink commentedon Feb 17, 2020
That's not the same type, it just prints "fn item" in a very similar way to "fn pointer". The former is zero-sized, while the latter is pointer-sized.
glandium commentedon Feb 17, 2020
Are you saying that the
{libc::unix::fread}part is supposed to indicate that?jonas-schievink commentedon Feb 17, 2020
Yeah, it indicates that it's the type of that specific fn item, and not an fn pointer.
glandium commentedon Feb 17, 2020
That... is really not obvious.
Centril commentedon Feb 17, 2020
I agree it isn't; but on the other hand I'm not sure what would be clear without also taking up a lot of space... ideas?
cc @estebank
estebank commentedon Feb 17, 2020
An option would be to move the function name after the fn instead of after the signature, but doubt that would be enough. Best bet would be to add extra wording to the message about this being a specific function and expecting a function pointer, but the wording of those two is too close and lends itself to the same confusion we have now. Because of that, I think we should add a note explaining the nuance for these cases.
jumbatm commentedon Feb 17, 2020
How about something like this?
I'd argue that confusion comes from seeing the "same" function signature so many times, so it's vital to distinguish between the individual function type vs the function pointer type as much (and as obviously) as possible.
1 remaining item
HTGAzureX1212 commentedon Mar 5, 2022
@rustbot assign
rustbot commentedon Mar 5, 2022
Error: Parsing assign command in comment failed: ...'bot assign' | error: specify user to assign to at >| ''...
Please let
@rust-lang/releaseknow if you're having trouble with this bot.HTGAzureX1212 commentedon Mar 5, 2022
@rustbot claim
[-]Error message for E0617 is confusing when functions are involved[/-][+]Printing function definition types can be confusing[/+][-]Printing function definition types can be confusing[/-][+]Printed function definition types can be confusing[/+]oriongonza commentedon Nov 27, 2024
@rustbot claim
Rollup merge of rust-lang#133538 - dev-ardi:69232-better-diag, r=comp…
Rollup merge of rust-lang#133538 - dev-ardi:69232-better-diag, r=comp…
Rollup merge of rust-lang#133538 - dev-ardi:69232-better-diag, r=comp…
Unrolled build for rust-lang#133538