Skip to content

Replace handwritten Debug impls with derives #4471

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

Merged
merged 1 commit into from
Jun 2, 2025

Conversation

tgross35
Copy link
Contributor

@tgross35 tgross35 commented Jun 2, 2025

s_no_extra_traits! doesn't derive Debug so there are a lot of handwritten implementations. However, since we have a derive-like solution for unions now (printing them like an opaque struct), there really isn't any reason these can't all be derived.

Add derive(Debug) to s_no_extra_traits, still gated behind feature = "extra_traits", which allows getting rid of manual implementations.

@rustbot
Copy link
Collaborator

rustbot commented Jun 2, 2025

Some changes occurred in OpenBSD module

cc @semarie

Some changes occurred in solarish module

cc @jclulow, @pfmooney

Some changes occurred in the Android module

cc @maurer

@tgross35 tgross35 force-pushed the no-handwritten-debug branch from d9d89d2 to 849a74e Compare June 2, 2025 04:43
`s_no_extra_traits!` doesn't derive `Debug` so there are a lot of
handwritten implementations. However, since we have a derive-like
solution for unions now (printing them like an opaque struct), there
really isn't any reason these can't all be derived.

Add `derive(Debug)` to `s_no_extra_traits`, still gated behind `feature
= "extra_traits"`, which allows getting rid of manual implementations.
@tgross35 tgross35 force-pushed the no-handwritten-debug branch from 849a74e to 65c39bf Compare June 2, 2025 05:04
@tgross35
Copy link
Contributor Author

tgross35 commented Jun 2, 2025

Verified that the following work:

rustc --print target-list | lines | find -v -r '^(aarch64-unknown-teeos|amdgcn-amd-amdhsa|avr-none|hexagon-unknown-none-elf|i686-unknown-hurd-gnu|i686-pc-nto-qnx700|m68k-unknown-.*|riscv64gc-unknown-netbsd|x86_64-lynx-lynxos178|x86_64-unknown-hurd-gnu|x86_64-unknown-linux-none|xtensa-esp32.*)$' | each { |$tgt| print $tgt; cargo c -p libc --target $tgt -Zbuild-std=core; cargo c -p libc --target $tgt --features extra_traits -Zbuild-std=core }
rustc --print target-list | lines | find freebsd | each { |tgt| for version in [11, 12, 13, 14, 15] { print $"($tgt) freebsd($version)"; RUST_LIBC_UNSTABLE_FREEBSD_VERSION=$version cargo c -p libc --target $tgt -Zbuild-std=core; RUST_LIBC_UNSTABLE_FREEBSD_VERSION=$version cargo c -p libc --target $tgt --features extra_traits -Zbuild-std=core } }

All of the skipped targets are failed on main (I'm a bit surprised about hurd)

@tgross35 tgross35 added the stable-nominated This PR should be considered for cherry-pick to libc's stable release branch label Jun 2, 2025
@tgross35 tgross35 added this pull request to the merge queue Jun 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 2, 2025
@tgross35 tgross35 added this pull request to the merge queue Jun 2, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 2, 2025
@tgross35 tgross35 added this pull request to the merge queue Jun 2, 2025
Merged via the queue into rust-lang:main with commit f332c21 Jun 2, 2025
51 of 52 checks passed
@tgross35 tgross35 deleted the no-handwritten-debug branch June 2, 2025 06:38
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Jun 3, 2025
`s_no_extra_traits!` doesn't derive `Debug` so there are a lot of
handwritten implementations. However, since we have a derive-like
solution for unions now (printing them like an opaque struct), there
really isn't any reason these can't all be derived.

Add `derive(Debug)` to `s_no_extra_traits`, still gated behind `feature
= "extra_traits"`, which allows getting rid of manual implementations.

(backport <rust-lang#4471>)
(cherry picked from commit 65c39bf)
@tgross35 tgross35 mentioned this pull request Jun 3, 2025
tgross35 added a commit to tgross35/rust-libc that referenced this pull request Jun 3, 2025
`s_no_extra_traits!` doesn't derive `Debug` so there are a lot of
handwritten implementations. However, since we have a derive-like
solution for unions now (printing them like an opaque struct), there
really isn't any reason these can't all be derived.

Add `derive(Debug)` to `s_no_extra_traits`, still gated behind `feature
= "extra_traits"`, which allows getting rid of manual implementations.

(backport <rust-lang#4471>)
(cherry picked from commit 65c39bf)
@tgross35 tgross35 added stable-applied This PR has been cherry-picked to libc's stable release branch and removed stable-nominated This PR should be considered for cherry-pick to libc's stable release branch labels Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants