-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Always implement Debug
#4624
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
Always implement Debug
#4624
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sigh ctest bugs... |
3b31fa6
to
18304d1
Compare
@rustbot blocked |
b4830f2
to
72577e7
Compare
0bb646d
to
c21ce4b
Compare
c21ce4b
to
67d81c2
Compare
Currently `Debug` implementations are gated behind the `extra-traits` feature. My understanding is that historically, this was for two reasons: 1. `Debug` implementations for unions were unsound 2. Concerns about compile time The first was resolved a while ago by adding a "manual derive" opaque implementation, in 6faa521 ("fix: make Debug impl for unions opaque"). Regarding the second reason, compile times for the current `main` on my machine are (cleaning in between, with the 2025-08-06 nightly): $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.64s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.85s And with this patch applied: $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.70s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.15s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.86s That is a microbenchmark but it shows that there probably isn't anything to worry about. Thus, remove the `Debug` implementation from the `feature = "extra_traitts"` gating. Another advantage of doing this is that it should allow many crates to remove the enable for `extra_traits`, giving us a better idea of who wants `Debug` vs. who is actually using the `Eq`/`Hash` implementations. Link: rust-lang#3880
67d81c2
to
504f16c
Compare
tgross35
added a commit
to tgross35/rust-libc
that referenced
this pull request
Sep 23, 2025
Currently `Debug` implementations are gated behind the `extra-traits` feature. My understanding is that historically, this was for two reasons: 1. `Debug` implementations for unions were unsound 2. Concerns about compile time The first was resolved a while ago by adding a "manual derive" opaque implementation, in 6faa521 ("fix: make Debug impl for unions opaque"). Regarding the second reason, compile times for the current `main` on my machine are (cleaning in between, with the 2025-08-06 nightly): $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.64s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.85s And with this patch applied: $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.70s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.15s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.86s That is a microbenchmark but it shows that there probably isn't anything to worry about. Thus, remove the `Debug` implementation from the `feature = "extra_traitts"` gating. Another advantage of doing this is that it should allow many crates to remove the enable for `extra_traits`, giving us a better idea of who wants `Debug` vs. who is actually using the `Eq`/`Hash` implementations. Link: rust-lang#3880 (backport <rust-lang#4624>) (cherry picked from commit a6e7563) [ needed to apply in a few more places - Trevor ]
Merged
tgross35
added a commit
to tgross35/rust-libc
that referenced
this pull request
Sep 23, 2025
Currently `Debug` implementations are gated behind the `extra-traits` feature. My understanding is that historically, this was for two reasons: 1. `Debug` implementations for unions were unsound 2. Concerns about compile time The first was resolved a while ago by adding a "manual derive" opaque implementation, in 6faa521 ("fix: make Debug impl for unions opaque"). Regarding the second reason, compile times for the current `main` on my machine are (cleaning in between, with the 2025-08-06 nightly): $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.64s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.85s And with this patch applied: $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.70s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.15s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.86s That is a microbenchmark but it shows that there probably isn't anything to worry about. Thus, remove the `Debug` implementation from the `feature = "extra_traitts"` gating. Another advantage of doing this is that it should allow many crates to remove the enable for `extra_traits`, giving us a better idea of who wants `Debug` vs. who is actually using the `Eq`/`Hash` implementations. Link: rust-lang#3880 (backport <rust-lang#4624>) (cherry picked from commit a6e7563) [ needed to apply in a few more places, including the e! macro definition - Trevor ]
tgross35
added a commit
to tgross35/rust-libc
that referenced
this pull request
Sep 23, 2025
Currently `Debug` implementations are gated behind the `extra-traits` feature. My understanding is that historically, this was for two reasons: 1. `Debug` implementations for unions were unsound 2. Concerns about compile time The first was resolved a while ago by adding a "manual derive" opaque implementation, in 6faa521 ("fix: make Debug impl for unions opaque"). Regarding the second reason, compile times for the current `main` on my machine are (cleaning in between, with the 2025-08-06 nightly): $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.64s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.85s And with this patch applied: $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.70s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.15s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.86s That is a microbenchmark but it shows that there probably isn't anything to worry about. Thus, remove the `Debug` implementation from the `feature = "extra_traitts"` gating. Another advantage of doing this is that it should allow many crates to remove the enable for `extra_traits`, giving us a better idea of who wants `Debug` vs. who is actually using the `Eq`/`Hash` implementations. Link: rust-lang#3880 (backport <rust-lang#4624>) (cherry picked from commit a6e7563) [ needed to apply in a few more places, including the e! macro definition - Trevor ]
tgross35
added a commit
to tgross35/rust-libc
that referenced
this pull request
Sep 23, 2025
Currently `Debug` implementations are gated behind the `extra-traits` feature. My understanding is that historically, this was for two reasons: 1. `Debug` implementations for unions were unsound 2. Concerns about compile time The first was resolved a while ago by adding a "manual derive" opaque implementation, in 6faa521 ("fix: make Debug impl for unions opaque"). Regarding the second reason, compile times for the current `main` on my machine are (cleaning in between, with the 2025-08-06 nightly): $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.64s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.85s And with this patch applied: $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.70s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.15s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.86s That is a microbenchmark but it shows that there probably isn't anything to worry about. Thus, remove the `Debug` implementation from the `feature = "extra_traitts"` gating. Another advantage of doing this is that it should allow many crates to remove the enable for `extra_traits`, giving us a better idea of who wants `Debug` vs. who is actually using the `Eq`/`Hash` implementations. Link: rust-lang#3880 (backport <rust-lang#4624>) (cherry picked from commit a6e7563) [ needed to apply in a few more places, including the e! macro definition - Trevor ]
github-merge-queue bot
pushed a commit
that referenced
this pull request
Sep 23, 2025
Currently `Debug` implementations are gated behind the `extra-traits` feature. My understanding is that historically, this was for two reasons: 1. `Debug` implementations for unions were unsound 2. Concerns about compile time The first was resolved a while ago by adding a "manual derive" opaque implementation, in 6faa521 ("fix: make Debug impl for unions opaque"). Regarding the second reason, compile times for the current `main` on my machine are (cleaning in between, with the 2025-08-06 nightly): $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.79s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.64s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.08s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.85s And with this patch applied: $ cargo build -p libc Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.89s $ cargo build -p libc --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.70s $ cargo build -p libc --features extra_traits Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.15s $ cargo build -p libc --features extra_traits --release Compiling libc v1.0.0-alpha.1 (~/rust-libc) Finished `release` profile [optimized] target(s) in 0.86s That is a microbenchmark but it shows that there probably isn't anything to worry about. Thus, remove the `Debug` implementation from the `feature = "extra_traitts"` gating. Another advantage of doing this is that it should allow many crates to remove the enable for `extra_traits`, giving us a better idea of who wants `Debug` vs. who is actually using the `Eq`/`Hash` implementations. Link: #3880 (backport <#4624>) (cherry picked from commit a6e7563) [ needed to apply in a few more places, including the e! macro definition - Trevor ]
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
O-android
O-dragonfly
O-linux
O-linux-like
O-macos
O-newlib
O-powerpc
O-redox
O-solarish
O-unix
O-wasi
O-windows
S-blocked
stable-applied
This PR has been cherry-picked to libc's stable release branch
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently
Debug
implementations are gated behind theextra-traits
feature. My understanding is that historically, this was for two reasons:Debug
implementations for unions were unsoundThe first was resolved a while ago by adding a "manual derive" opaque implementation, in 6faa521 ("fix: make Debug impl for unions opaque"). Regarding the second reason, compile times for the current
main
on my machine are (cleaning in between, with the 2025-08-06 nightly):And with this patch applied:
That is a microbenchmark but it shows that there probably isn't anything to worry about.
Thus, remove the
Debug
implementation from thefeature = "extra_traitts"
gating.Another advantage of doing this is that it should allow many crates to remove the enable for
extra_traits
, giving us a better idea of who wantsDebug
vs. who is actually using theEq
/Hash
implementations.Link: #3880