Skip to content

fix(ctest): cast fn pointers as *const ()#4831

Merged
JohnTitor merged 1 commit intorust-lang:mainfrom
JohnTitor:fix/cast-fn-int-pointer
Nov 17, 2025
Merged

fix(ctest): cast fn pointers as *const ()#4831
JohnTitor merged 1 commit intorust-lang:mainfrom
JohnTitor:fix/cast-fn-int-pointer

Conversation

@JohnTitor
Copy link
Copy Markdown
Member

@JohnTitor JohnTitor commented Nov 16, 2025

Description

This fixes a newly added lint warning:

error: direct cast of function item into an integer
   --> /Users/runner/work/libc/libc/target/aarch64-apple-darwin/debug/build/ctest-test-d036828d8ecc10e7/out/t2gen.rs:577:28
    |
577 |         let expected = T2a as u64;
    |                            ^^^^^^
    |
note: the lint level is defined here
   --> ctest-test/src/bin/t2.rs:2:9
    |
  2 | #![deny(warnings)]
    |         ^^^^^^^^
    = note: `#[deny(function_casts_as_integer)]` implied by `#[deny(warnings)]`
help: first cast to a pointer `as *const ()`
    |
577 |         let expected = T2a as *const () as u64;
    |                            ++++++++++++

error: could not compile `ctest-test` (bin "t2") due to 1 previous error

Sources

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

@rustbot rustbot added the ctest Issues relating to the ctest crate label Nov 16, 2025
@JohnTitor JohnTitor force-pushed the fix/cast-fn-int-pointer branch from 04fcf11 to 36a2328 Compare November 16, 2025 22:08
@JohnTitor JohnTitor marked this pull request as ready for review November 16, 2025 22:14
@JohnTitor JohnTitor added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Nov 16, 2025
@JohnTitor JohnTitor enabled auto-merge November 16, 2025 22:15
@JohnTitor JohnTitor added this pull request to the merge queue Nov 16, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 16, 2025
@JohnTitor JohnTitor added this pull request to the merge queue Nov 17, 2025
Merged via the queue into rust-lang:main with commit a5e5c0d Nov 17, 2025
51 of 52 checks passed
@JohnTitor JohnTitor deleted the fix/cast-fn-int-pointer branch November 17, 2025 11:11
@tgross35 tgross35 added stable-unneeded This PR is applied to main but already exists on libc-0.2 and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Nov 19, 2025
@alex
Copy link
Copy Markdown
Member

alex commented Jan 27, 2026

This warning looks to be on by default in rust 1.93.0. Anything that can be done to help with a ctest release?

@tgross35
Copy link
Copy Markdown
Contributor

Are you using the latest ctest alpha? It should be fixed there.

As far as an actual minor release, I don't think there's any reason not to do that at this point. I'll reach out to the author of the new implementation.

@alex
Copy link
Copy Markdown
Member

alex commented Jan 27, 2026

We're not currently pointed at the alpha, we can certainly do that in the short term. I think having things as a stable minor release is a bit of a happier path (since cargo can pick them up automatically)

@tgross35
Copy link
Copy Markdown
Contributor

It will be a minor release but Cargo won't auto-upgrade 0.4.x to 0.5.0, that's semver-incompatible. You'll have to do some API changes to upgrade to the alpha and the future 0.5.

@alex
Copy link
Copy Markdown
Member

alex commented Jan 27, 2026

👍 thanks much! Cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ctest Issues relating to the ctest crate stable-unneeded This PR is applied to main but already exists on libc-0.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants