Uh oh!
There was an error while loading. Please reload this page.
Replace all fmt.pad with debug_struct - #84013
Conversation
rust-highfive
commented
Apr 8, 2021
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
i guess this is fine since use std::fmt;structA;structB;impl fmt::DebugforA{fnfmt(&self,f:&mut fmt::Formatter<'_>) -> fmt::Result{
f.debug_struct("X").finish()}}impl fmt::DebugforB{fnfmt(&self,f:&mut fmt::Formatter<'_>) -> fmt::Result{
f.pad("X")}}fnmain(){assert_eq!(format!("<{:3?}>",A),"<X>");assert_eq!(format!("<{:3?}>",B),"<X >");}(sending this to a real T-libs member) r? @m-ou-se |
m-ou-se
commented
Apr 21, 2021
Some of these should probably use (I replaced a bunch of those recently in #83558, but I missed these since they used |
m-ou-se
commented
Apr 21, 2021
We somewhat regularly change or improve #[derive(Debug)]structA{x:i32,y:i32,}fnmain(){println!("{:#010?}",A{ x:1, y:2});}The only downside of the change in this PR is that in 'pretty' mode ( taking up a lot more space than |
CDirkx
commented
Apr 21, 2021
I agree with the use of I also found two more cases ( |
m-ou-se
commented
Apr 21, 2021
Thanks! @bors r+ |
bors
commented
Apr 21, 2021
📌 Commit fdae757 has been approved by |
This comment has been minimized.
This comment has been minimized.
m-ou-se
commented
Apr 21, 2021
@bors r- |
CDirkx
commented
Apr 21, 2021
I fixed |
m-ou-se
commented
Apr 21, 2021
@bors r+ |
bors
commented
Apr 21, 2021
📌 Commit fccc75c has been approved by |
bors
commented
Apr 21, 2021
🌲 The tree is currently closed for pull requests below priority 1000. This pull request will be tested once the tree is reopened. |
Replace all `fmt.pad` with `debug_struct`
This replaces any occurrence of:
- `f.pad("X")` with `f.debug_struct("X").finish()`
- `f.pad("X { .. }")` with `f.debug_struct("X").finish_non_exhaustive()`
This is in line with existing formatting code such as
https://github.com/rust-lang/rust/blob/125505306744a0a5bb01d62337260a95d9ff8d57/library/std/src/sync/mpsc/mod.rs#L1470-L1475Rollup of 12 pull requests Successful merges: - rust-lang#84013 (Replace all `fmt.pad` with `debug_struct`) - rust-lang#84119 (Move `sys::vxworks` code to `sys::unix`) - rust-lang#84212 (Replace `Void` in `sys` with never type) - rust-lang#84251 (fix 'const-stable since' for NonZeroU*::new_unchecked) - rust-lang#84301 (Document that `index` and `index_mut` can panic) - rust-lang#84365 (Improve the docstrings of the `Lto` struct.) - rust-lang#84378 (Fix broken doc link) - rust-lang#84379 (Add GAT related tests) - rust-lang#84380 (Write Rustdoc titles like "x in crate::mod - Rust") - rust-lang#84390 (Format `Struct { .. }` on one line even with `{:#?}`.) - rust-lang#84393 (Support `x.py doc std --open`) - rust-lang#84406 (Remove `delete` alias from `mem::drop`.) Failed merges: - rust-lang#84387 (Move `sys_common::poison` to `sync::poison`) r? `@ghost` `@rustbot` modify labels: rollup
This replaces any occurrence of:
f.pad("X")withf.debug_struct("X").finish()f.pad("X { .. }")withf.debug_struct("X").finish_non_exhaustive()This is in line with existing formatting code such as
rust/library/std/src/sync/mpsc/mod.rs
Lines 1470 to 1475 in 1255053