Skip to content

[rustc_abi] Customize Debug for Primitive and Scalar#159539

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scottmcm:nicer-rustc_abi-primitive-debug
Jul 19, 2026
Merged

[rustc_abi] Customize Debug for Primitive and Scalar#159539
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
scottmcm:nicer-rustc_abi-primitive-debug

Conversation

@scottmcm

@scottmcm scottmcm commented Jul 18, 2026

Copy link
Copy Markdown
Member

Of late I've been looking at layout a bunch, which means staring at things like

backend_repr: ScalarPair {
    a: Initialized {
        value: Int(
            I8,
            false,
        ),
        valid_range: 0..=1,
    },
    b: Union {
        value: Int(
            I8,
            false,
        ),
    },
    b_offset: Size(1 bytes),
},

and that's just kinda long and unfriendly.

Thus this PR that just changes Debug -- nothing else! -- so for example that shows as

backend_repr: ScalarPair {
    a: u8 is 0..=1,
    b: union u8,
    b_offset: Size(1 bytes),
},

EDIT: oh, net -1404 lines is a pretty good summary of why 🙃

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 18, 2026
@rust-log-analyzer

This comment has been minimized.

@scottmcm
scottmcm force-pushed the nicer-rustc_abi-primitive-debug branch from b3c3b51 to a5fe990 Compare July 19, 2026 02:40
@scottmcm
scottmcm marked this pull request as ready for review July 19, 2026 05:31
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 19, 2026
@rustbot

rustbot commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 17 candidates

Of late I've been looking at layout a bunch, which means staring at things like

```rust
backend_repr: ScalarPair {
    a: Initialized {
        value: Int(
            I8,
            false,
        ),
        valid_range: 0..=1,
    },
    b: Union {
        value: Int(
            I8,
            false,
        ),
    },
    b_offset: Size(1 bytes),
},
```

and that's just kinda long and unfriendly.

Thus this PR that just changes `Debug` -- nothing else! -- so for example that shows as

```rust
backend_repr: ScalarPair {
    a: u8 is 0..=1,
    b: union u8,
    b_offset: Size(1 bytes),
},
```
@scottmcm
scottmcm force-pushed the nicer-rustc_abi-primitive-debug branch from a5fe990 to d0c3ca1 Compare July 19, 2026 06:29

@jieyouxu jieyouxu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +1499 to +1501
// `u8 is (..=0) | (1..)` instead of `u8 is ..` is the information
// you needed because the problem is that despite being *a* full
// range it's not *the* canonical one you expected it was.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines -92 to +77
Initialized {
value: Int(
I16,
true,
),
valid_range: (..=1) | (65535..),
},
i16 is -1..=1,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: yeah, this is indeed nicer

Comment on lines -298 to +232
Initialized {
value: Int(
I32,
true,
),
valid_range: 0..=4294967295,
},
i32 is ..,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remark: this is also nicer because it's easier to notice in the diff whether the range is actually canonically full versus the end range happens to be ${i,u}N::MAX - 1.

Comment thread tests/ui/layout/enum-scalar-pair-int-ptr.rs
@rust-bors

This comment was marked as resolved.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 19, 2026
@jieyouxu

Copy link
Copy Markdown
Member

Actually just r=me after PR CI is green just in case.
@bors r-

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 19, 2026
@rust-bors

This comment was marked as resolved.

@scottmcm

Copy link
Copy Markdown
Member Author

@bors r=jieyouxu

@rust-bors

rust-bors Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d0c3ca1 has been approved by jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 19, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 19, 2026
Rollup of 5 pull requests

Successful merges:

 - #158546 (Move `std::io::BufRead` to `alloc::io`)
 - #159372 (Remove SIZE generic param from DisplayBuffer in core::net)
 - #159548 (miri subtree update)
 - #159508 (Some cleanup in `rustc_attr_parsing`)
 - #159539 ([rustc_abi] Customize `Debug` for `Primitive` and `Scalar`)
@rust-bors
rust-bors Bot merged commit 152f857 into rust-lang:main Jul 19, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 19, 2026
rust-timer added a commit that referenced this pull request Jul 19, 2026
Rollup merge of #159539 - scottmcm:nicer-rustc_abi-primitive-debug, r=jieyouxu

[rustc_abi] Customize `Debug` for `Primitive` and `Scalar`

Of late I've been looking at layout a bunch, which means staring at things like

```rust
backend_repr: ScalarPair {
    a: Initialized {
        value: Int(
            I8,
            false,
        ),
        valid_range: 0..=1,
    },
    b: Union {
        value: Int(
            I8,
            false,
        ),
    },
    b_offset: Size(1 bytes),
},
```

and that's just kinda long and unfriendly.

Thus this PR that just changes `Debug` -- nothing else! -- so for example that shows as

```rust
backend_repr: ScalarPair {
    a: u8 is 0..=1,
    b: union u8,
    b_offset: Size(1 bytes),
},
```

---

EDIT: oh, net -1404 lines is a pretty good summary of why 🙃
@scottmcm
scottmcm deleted the nicer-rustc_abi-primitive-debug branch July 19, 2026 19:29
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Jul 22, 2026
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#158546 (Move `std::io::BufRead` to `alloc::io`)
 - rust-lang/rust#159372 (Remove SIZE generic param from DisplayBuffer in core::net)
 - rust-lang/rust#159548 (miri subtree update)
 - rust-lang/rust#159508 (Some cleanup in `rustc_attr_parsing`)
 - rust-lang/rust#159539 ([rustc_abi] Customize `Debug` for `Primitive` and `Scalar`)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants