Commit Graph

8 Commits

Author SHA1 Message Date
Mara Bos
5b763fb1b7 Add test for new format_args!() temporary lifetimes. 2025-06-18 10:20:20 +02:00
bors
0ce1369bde Auto merge of #136974 - m-ou-se:fmt-options-64-bit, r=scottmcm
Reduce FormattingOptions to 64 bits

This is part of https://github.com/rust-lang/rust/issues/99012

This reduces FormattingOptions from 6-7 machine words (384 bits on 64-bit platforms, 224 bits on 32-bit platforms) to just 64 bits (a single register on 64-bit platforms).

Before:

```rust
pub struct FormattingOptions {
    flags: u32, // only 6 bits used
    fill: char,
    align: Option<Alignment>,
    width: Option<usize>,
    precision: Option<usize>,
}
```

After:

```rust
pub struct FormattingOptions {
    /// Bits:
    ///  - 0-20: fill character (21 bits, a full `char`)
    ///  - 21: `+` flag
    ///  - 22: `-` flag
    ///  - 23: `#` flag
    ///  - 24: `0` flag
    ///  - 25: `x?` flag
    ///  - 26: `X?` flag
    ///  - 27: Width flag (if set, the width field below is used)
    ///  - 28: Precision flag (if set, the precision field below is used)
    ///  - 29-30: Alignment (0: Left, 1: Right, 2: Center, 3: Unknown)
    ///  - 31: Always set to 1
    flags: u32,
    /// Width if width flag above is set. Otherwise, always 0.
    width: u16,
    /// Precision if precision flag above is set. Otherwise, always 0.
    precision: u16,
}
```
2025-03-22 10:56:14 +00:00
Mara Bos
d7685f0d0b Add test for Formatter flags. 2025-03-21 17:05:56 +01:00
bjorn3
7f4d3bd6af Remove the regex dependency from coretests
It is only used by a single test, yet would take up unnecessary space
once stdlib deps get vendored.
2025-03-18 09:34:01 +00:00
Martin Nordholts
697737a8b1 core: Make Debug impl of raw pointers print metadata if present
Make Rust pointers less magic by including metadata information in their
`Debug` output.

This does not break Rust stability guarantees because `Debug` output is
explicitly exempted from stability:
https://doc.rust-lang.org/std/fmt/trait.Debug.html#stability

Co-authored-by: Lukas <26522220+lukas-code@users.noreply.github.com>
Co-authored-by: Josh Stone <cuviper@gmail.com>
2025-02-15 17:27:55 +01:00
Martin Nordholts
9479b6f0ea tests: Add regression test for Debug impl of raw pointers 2025-02-15 17:22:45 +01:00
Martin Nordholts
7176320821 tests: Use as *const _ instead of .as_ptr() in ptr fmt test
Because `.as_ptr()` changes the type of the pointer (e.g. `&[u8]`
becomes `*const u8` instead of `*const [u8]`), and it can't be expected
that different types will be formatted the same way.
2025-02-15 17:02:54 +01:00
bjorn3
b6a3841942 Put all coretests in a separate crate 2025-01-26 10:26:36 +00:00