Trying to return c_void
should suggest to return ()
instead
#100972
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
D-lack-of-suggestion
Diagnostics: Adding a (structured) suggestion would increase the quality of the diagnostic.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
e.g. this irlo thread was likely the result of someone translating a
void
-returning C function to ac_void
-returning Rust function.Given the following:
The current output is:
Ideally, this should also contain a help message along the lines of
and a suggestion to remove the
-> c_void
.It might be reasonable to have this as a dedicated warning lint for
-> c_void
either instead of or in addition to help on the type mismatch error, as writing bindings toextern "C" { fn foo() -> c_void; }
is wrong but won't get a type mismatch error. This probably should go straight to a rustc lint rather than in clippy due to the practically-100% applicability.It might also be beneficial to do more thorough linting of misuse of
c_void
(basically any use that isn't*mut c_void
or*const c_void
(or maybeptr::NonNull<c_void>
), but that is a separate issue from teaching in this error.The text was updated successfully, but these errors were encountered: