Guillaume Gomez
015e9371e0
Rollup merge of #123940 - kornelski:remove-derived-debug, r=Urgau
...
debug-fmt-detail option
I'd like to propose a new option that makes `#[derive(Debug)]` generate no-op implementations that don't print anything, and makes `{:?}` in format strings a no-op.
There are a couple of motivations for this:
1. A more thorough stripping of debug symbols. Binaries stripped of debug symbols still retain some of them through `Debug` implementations. It's hard to avoid that without compiler's help, because debug formatting can be used in many places, including dependencies, and their loggers, asserts, panics, etc.
* In my testing it gives about 2% binary size reduction on top of all other binary-minimizing best practices (including `panic_immediate_abort`). There are targets like Web WASM or embedded where users pay attention to binary sizes.
* Users distributing closed-source binaries may not want to "leak" any symbol names as a matter of principle.
2. Adds ability to test whether code depends on specifics of the `Debug` format implementation in unwise ways (e.g. trying to get data unavailable via public interface, or using it as a serialization format). Because current Rust's debug implementation doesn't change, there's a risk of it becoming a fragile de-facto API that [won't be possible to change in the future](https://www.hyrumslaw.com/ ). An option that "breaks" it can act as a [grease](https://www.rfc-editor.org/rfc/rfc8701.html ).
This implementation is a `-Z fmt-debug=opt` flag that takes:
* `full` — the default, current state.
* `none` — makes derived `Debug` and `{:?}` no-ops. Explicit `impl Debug for T` implementations are left unharmed, but `{:?}` format won't use them, so they may get dead-code eliminated if they aren't invoked directly.
* `shallow` — makes derived `Debug` print only the type's name, without recursing into fields. Fieldless enums print their variant names. `{:?}` works.
The `shallow` option is a compromise between minimizing the `Debug` code, and compatibility. There are popular proc-macro crates that use `Debug::fmt` as a way to convert enum values into their Rust source code.
There's a corresponding `cfg` flag: `#[cfg(fmt_debug = "none")]` that can be used in user code to react to this setting to minimize custom `Debug` implementations or remove unnecessary formatting helper functions.
2024-08-29 16:21:46 +02:00
..
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-02-16 20:02:50 +00:00
2023-09-29 21:56:57 +02:00
2023-10-08 20:17:53 -07:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-12 11:02:57 +01:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-04-07 13:30:12 -04:00
2024-04-07 13:30:12 -04:00
2024-07-17 11:01:29 +01:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-02-24 19:49:16 +00:00
2024-02-24 19:49:16 +00:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-04-06 11:21:47 -04:00
2024-04-06 11:21:47 -04:00
2024-01-13 12:46:58 -05:00
2023-12-23 00:52:42 +01:00
2024-01-13 12:46:58 -05:00
2024-05-04 11:30:38 +02:00
2024-05-04 11:30:38 +02:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-02-08 08:10:43 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-04-24 08:05:29 +00:00
2024-04-24 08:05:29 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-08-19 01:14:22 +01:00
2024-02-16 20:02:50 +00:00
2024-02-11 15:12:10 +01:00
2024-02-11 15:12:10 +01:00
2024-04-24 08:05:29 +00:00
2024-08-10 14:32:55 +03:00
2024-04-24 08:05:29 +00:00
2023-09-08 12:46:09 +01:00
2024-01-13 12:46:58 -05:00
2024-02-08 08:10:43 +00:00
2024-02-08 08:10:43 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-03-20 22:30:27 +01:00
2024-03-20 22:30:27 +01:00
2024-08-13 04:26:48 +08:00
2024-08-13 04:26:48 +08:00
2024-04-30 22:27:19 +02:00
2024-04-30 22:27:19 +02:00
2023-10-29 23:55:46 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-08-10 12:07:17 +02:00
2024-08-10 12:07:17 +02:00
2024-01-13 12:46:58 -05:00
2024-07-24 21:03:27 +00:00
2024-01-13 12:46:58 -05:00
2024-04-03 16:03:22 -04:00
2024-04-03 16:03:22 -04:00
2024-04-03 16:03:22 -04:00
2024-04-03 16:03:22 -04:00
2024-04-03 16:03:22 -04:00
2024-04-03 16:03:22 -04:00
2023-12-20 18:16:28 +01:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-08-28 23:32:40 +01:00
2024-08-28 23:32:40 +01:00
2024-01-13 12:46:58 -05:00
2024-01-12 14:11:16 +03:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-29 14:10:29 +00:00
2024-02-29 14:10:29 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2023-12-12 20:13:37 +00:00
2024-02-16 20:02:50 +00:00
2024-03-18 16:08:58 +00:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-05-20 09:18:49 +02:00
2024-05-20 09:18:49 +02:00
2024-01-09 21:08:16 +00:00
2024-03-07 14:26:31 +00:00
2024-01-07 18:00:03 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-04-07 13:30:12 -04:00
2024-04-07 13:30:12 -04:00
2024-04-17 13:00:43 +02:00
2024-04-17 13:00:43 +02:00
2024-01-13 12:46:58 -05:00
2023-12-05 19:53:59 +00:00
2024-08-17 12:43:25 -04:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2023-11-30 08:26:13 -08:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-06-13 22:12:26 -03:00
2024-06-13 22:12:26 -03:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-02 13:49:47 +01:00
2024-01-02 13:49:48 +01:00
2024-07-26 16:35:05 +03:00
2024-07-26 16:35:05 +03:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-03-27 11:20:28 -04:00
2024-03-27 11:20:28 -04:00
2024-02-16 20:02:50 +00:00
2024-02-08 08:10:43 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-07-05 00:52:01 +00:00
2023-11-24 19:15:52 +01:00
2024-01-09 17:00:24 +01:00
2024-01-15 21:24:13 +00:00
2024-02-01 20:01:05 +01:00
2024-02-01 20:01:05 +01:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-07-29 17:50:12 +01:00
2024-07-29 17:50:12 +01:00
2024-06-08 18:17:55 +02:00
2024-06-08 18:17:55 +02:00
2024-01-13 12:46:58 -05:00
2024-06-24 16:08:51 +03:00
2023-11-24 19:15:52 +01:00
2024-06-25 19:00:02 +02:00
2024-06-25 19:00:02 +02:00
2024-03-03 13:10:15 +01:00
2024-03-03 13:10:15 +01:00
2024-03-05 23:34:45 -05:00
2024-03-05 23:34:45 -05:00
2023-10-27 19:56:12 +02:00
2023-12-04 11:56:21 +01:00
2024-01-13 12:46:58 -05:00
2024-04-25 07:58:31 +02:00
2024-04-25 07:58:31 +02:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-08-06 11:17:26 +02:00
2024-04-23 21:30:59 -07:00
2024-04-23 21:30:59 -07:00
2024-06-28 14:20:43 -04:00
2024-06-28 14:20:43 -04:00
2024-06-28 14:20:43 -04:00
2024-01-13 12:46:58 -05:00
2023-11-24 19:15:52 +01:00
2024-03-22 13:30:48 -07:00
2024-03-22 13:30:48 -07:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-08-02 02:29:15 +05:30
2024-08-02 02:29:15 +05:30
2024-06-18 04:14:43 +08:00
2024-06-18 04:14:43 +08:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2023-10-23 13:04:47 -07:00
2024-06-24 16:08:51 +03:00
2024-01-13 12:46:58 -05:00
2024-04-11 16:39:06 +00:00
2024-04-22 16:28:20 +00:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-08-28 09:54:23 +02:00
2024-08-28 09:54:23 +02:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-22 14:24:31 +00:00
2024-01-22 14:24:31 +00:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-03-18 16:08:58 +00:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-05-30 22:52:33 +02:00
2024-07-06 23:29:58 +08:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-12 12:47:31 +08:00
2024-02-12 12:47:31 +08:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2024-01-03 18:59:42 +00:00
2023-11-24 19:15:52 +01:00
2024-01-13 12:46:58 -05:00
2024-07-17 11:01:29 +01:00
2024-07-17 11:01:29 +01:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-04-28 19:27:05 +01:00
2023-11-24 19:15:52 +01:00
2024-07-11 19:00:49 -07:00
2024-07-11 19:00:49 -07:00
2024-07-12 23:30:22 +05:30
2024-07-12 23:30:22 +05:30
2024-04-09 23:58:18 +02:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-02-08 08:10:43 +00:00
2024-02-08 08:10:43 +00:00
2024-01-29 17:43:07 +08:00
2024-01-29 17:43:07 +08:00
2024-05-21 20:16:39 +00:00
2024-05-21 20:16:39 +00:00
2024-02-16 20:02:50 +00:00
2024-06-24 17:12:08 +03:00
2024-02-16 20:02:50 +00:00
2023-10-05 01:04:41 +00:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-06-24 16:08:51 +03:00
2024-01-29 17:43:07 +08:00
2024-01-29 17:43:07 +08:00
2024-06-24 16:08:51 +03:00
2024-01-13 12:46:58 -05:00
2024-05-20 11:13:10 -04:00
2024-05-20 11:13:10 -04:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2024-05-20 19:55:59 -07:00
2024-05-20 19:55:59 -07:00
2024-02-16 20:02:50 +00:00
2024-01-13 12:46:58 -05:00
2023-11-24 19:15:52 +01:00
2024-07-30 14:08:02 +00:00