Skip to content

Commit 8af99df

Browse files
committed
Remove the 'always set' bit from FormattingOptions.
We don't need it anymore.
1 parent fd6c241 commit 8af99df

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

compiler/rustc_ast_lowering/src/format.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,8 @@ fn expand_format_args<'hir>(
391391
| ((o.debug_hex == Some(FormatDebugHex::Upper)) as u32) << 26
392392
| (o.width.is_some() as u32) << 27
393393
| (o.precision.is_some() as u32) << 28
394-
| align << 29
395-
| 1 << 31;
396-
if flags != 0xE000_0020 {
394+
| align << 29;
395+
if flags != 0x6000_0020 {
397396
bytecode[i] |= 1;
398397
bytecode.extend_from_slice(&flags.to_le_bytes());
399398
if let Some(val) = &o.width {

library/core/src/fmt/mod.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub struct FormattingOptions {
289289
/// ```text
290290
/// 31 30 29 28 27 26 25 24 23 22 21 20 0
291291
/// ┌───┬───────┬───┬───┬───┬───┬───┬───┬───┬───┬──────────────────────────────────┐
292-
/// │ 1 │ align │ p │ w │ X?│ x?│'0'│ # │ - │ + │ fill │
292+
/// │ 0 │ align │ p │ w │ X?│ x?│'0'│ # │ - │ + │ fill │
293293
/// └───┴───────┴───┴───┴───┴───┴───┴───┴───┴───┴──────────────────────────────────┘
294294
/// │ │ │ │ └─┬───────────────────┘ └─┬──────────────────────────────┘
295295
/// │ │ │ │ │ └─ The fill character (21 bits char).
@@ -300,10 +300,7 @@ pub struct FormattingOptions {
300300
/// │ ├─ 1: Align right. (>)
301301
/// │ ├─ 2: Align center. (^)
302302
/// │ └─ 3: Alignment not set. (default)
303-
/// └─ Always set.
304-
/// This makes it possible to distinguish formatting flags from
305-
/// a &str size when stored in (the upper bits of) the same field.
306-
/// (fmt::Arguments will make use of this property in the future.)
303+
/// └─ Always zero.
307304
/// ```
308305
// Note: This could use a special niche type with range 0x8000_0000..=0xfdd0ffff.
309306
// It's unclear if that's useful, though.
@@ -329,7 +326,6 @@ mod flags {
329326
pub(super) const ALIGN_RIGHT: u32 = 1 << 29;
330327
pub(super) const ALIGN_CENTER: u32 = 2 << 29;
331328
pub(super) const ALIGN_UNKNOWN: u32 = 3 << 29;
332-
pub(super) const ALWAYS_SET: u32 = 1 << 31;
333329
}
334330

335331
impl FormattingOptions {
@@ -345,11 +341,7 @@ impl FormattingOptions {
345341
/// - no [`DebugAsHex`] output mode.
346342
#[unstable(feature = "formatting_options", issue = "118117")]
347343
pub const fn new() -> Self {
348-
Self {
349-
flags: ' ' as u32 | flags::ALIGN_UNKNOWN | flags::ALWAYS_SET,
350-
width: 0,
351-
precision: 0,
352-
}
344+
Self { flags: ' ' as u32 | flags::ALIGN_UNKNOWN, width: 0, precision: 0 }
353345
}
354346

355347
/// Sets or removes the sign (the `+` or the `-` flag).

0 commit comments

Comments
 (0)