Skip to content

Fix c_void_returns lint warning#5240

Merged
tgross35 merged 1 commit into
rust-lang:mainfrom
jchlanda:jakub/c_void_ret_fix
Jul 2, 2026
Merged

Fix c_void_returns lint warning#5240
tgross35 merged 1 commit into
rust-lang:mainfrom
jchlanda:jakub/c_void_ret_fix

Conversation

@jchlanda

@jchlanda jchlanda commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Description

Nightly added a lint warning on c_void returns this patch removes the return type to implicitly return ().

See a sample failing job here: https://github.com/rust-lang/libc/actions/runs/28580626120/job/84739740809?pr=5065#step:9:2195

Checklist

  • Relevant tests in libc-test/semver have been updated
  • No placeholder or unstable values like *LAST or *MAX are
    included (see #3131)
  • Tested locally (cd libc-test && cargo test --target mytarget);
    especially relevant for platforms that may not be checked in CI

@jchlanda

jchlanda commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

cc: @folkertdev

@folkertdev

Copy link
Copy Markdown
Contributor

there is one more at

--- a/src/teeos/mod.rs
+++ b/src/teeos/mod.rs
@@ -49,7 +49,7 @@ pub type clockid_t = c_int;
 
 pub type suseconds_t = c_long;
 
-pub type once_fn = extern "C" fn() -> c_void;
+pub type once_fn = extern "C" fn();
 
 pub type pthread_once_t = c_int;

@folkertdev

Copy link
Copy Markdown
Contributor

also this is technically a breaking change? but the old signature was incorrect so idk.

@tgross35

tgross35 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

also this is technically a breaking change? but the old signature was incorrect so idk.

Technically yes, but the relevant platforms are all T3 and the return type is kind of useless so this will be fine.

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Jul 2, 2026
@jchlanda

jchlanda commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

there is one more at

--- a/src/teeos/mod.rs
+++ b/src/teeos/mod.rs
@@ -49,7 +49,7 @@ pub type clockid_t = c_int;
 
 pub type suseconds_t = c_long;
 
-pub type once_fn = extern "C" fn() -> c_void;
+pub type once_fn = extern "C" fn();
 
 pub type pthread_once_t = c_int;

I wasn't sure about that one, as opposed to the other places, this is a function pointer type. The compiler doesn't seem to be complaining about it: https://rust.godbolt.org/z/3xTezqxrY
And the jobs are all 🟢

@tgross35

tgross35 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

I assume the lint just doesn't catch function pointer types (yet), it would be good to make that change here as well

@jchlanda jchlanda force-pushed the jakub/c_void_ret_fix branch from 41f93df to 8b2a533 Compare July 2, 2026 10:23
@folkertdev

Copy link
Copy Markdown
Contributor

It's odd, based on the tests the lint should fire

https://github.com/rust-lang/rust/blob/c397dae808f70caebab1fc4e11b3edf7e59f58c7/tests/ui/lint/c-void-returns.rs#L20

So maybe that file does not get run in CI? Anyhow, further evidence that we should make the change there too.

@jchlanda

jchlanda commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Done now, thank you.

@tgross35 tgross35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgross35 tgross35 enabled auto-merge July 2, 2026 10:29
@tgross35 tgross35 added this pull request to the merge queue Jul 2, 2026
Merged via the queue into rust-lang:main with commit 7c0abcb Jul 2, 2026
56 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stable-nominated This PR should be considered for cherry-pick to libc's stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants