diff options
| author | Ralf Jung <post@ralfj.de> | 2022-04-30 18:30:11 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2022-05-06 10:57:03 +0200 |
| commit | bd31ba045dca8165a4cb9dfb9a754ddc98e15009 (patch) | |
| tree | c3fd3313df54bf6997280e7e57351c517699edc6 /compiler/rustc_target | |
| parent | 9714e139ffb25f3b96b28110ae81677c8c1a7cf2 (diff) | |
| download | rust-bd31ba045dca8165a4cb9dfb9a754ddc98e15009.tar.gz rust-bd31ba045dca8165a4cb9dfb9a754ddc98e15009.zip | |
make Size and Align debug-printing a bit more compact
Diffstat (limited to 'compiler/rustc_target')
| -rw-r--r-- | compiler/rustc_target/src/abi/mod.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index 0e8fd9cc93f..a2cd3c4c468 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -276,12 +276,19 @@ impl ToJson for Endian { } /// Size of a type in bytes. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)] #[derive(HashStable_Generic)] pub struct Size { raw: u64, } +// This is debug-printed a lot in larger structs, don't waste too much space there +impl fmt::Debug for Size { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Size({} bytes)", self.bytes()) + } +} + impl Size { pub const ZERO: Size = Size { raw: 0 }; @@ -485,12 +492,19 @@ impl Step for Size { } /// Alignment of a type in bytes (always a power of two). -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encodable, Decodable)] #[derive(HashStable_Generic)] pub struct Align { pow2: u8, } +// This is debug-printed a lot in larger structs, don't waste too much space there +impl fmt::Debug for Align { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Align({} bytes)", self.bytes()) + } +} + impl Align { pub const ONE: Align = Align { pow2: 0 }; |
