-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Problem
rustc supports the -Zfmt-debug option. When enabled, #[derive(Debug)] and {:?} generate a no-op implementation. This can be useful, for instance, to further strip debug symbols and debug code from a binary. See the implementation PR for a more complete description.
Currently, to use this feature, one needs to add the option manually to RUSTFLAGS when using cargo build.
Proposed Solution
This feature could be available in cargo as a new profile setting called debug-format. It would make it easier to use and it would allow users to define a different value depending on the profile. It would look like this:
# Cargo.toml
cargo-features = ["debug-format"] # or use the unstable flag: `cargo build -Zdebug-format`
[package]
# ...
[profile.release]
debug-format = "none"The possible values would be the same as the one exposed by rustc: full, none, and shallow.
It could also be possible to have by default the value none for the release profile, and full for the dev profile.
Notes
- rustc tracking issue: Tracking Issue for fmt-debug option rust#129709
- rustc implementation PR: debug-fmt-detail option rust#123940
- If the issue gets accepted, I'm willing to work on this and provide an implementation.