Skip to content

Conversation

@SpriteOvO
Copy link
Member

@SpriteOvO SpriteOvO commented Jan 17, 2026

Follow-up #151123 (comment). Quotes:

@Skgland:

I'm not sure whether we should use usize or u64 here to represent the bit width.

My expectation would be u32 matching the associated {u,i}N::BITS123 constant that already exists on the integer types.

@SpriteOvO:

I found some previous discussions regarding the type of ::BITS constant. And during the stabilization of ::BITS, the choice of u32 affected some ecosystem crates (#81654), but soon after, these crates all accepted the u32 type.

So I think it makes sense to keep the type consistent with ::BITS here. Then I'd also like to change the name from bit_width to bits, also for consistency.

r? @oli-obk

Footnotes

  1. https://doc.rust-lang.org/std/primitive.i8.html#associatedconstant.BITS

  2. https://doc.rust-lang.org/std/primitive.i128.html#associatedconstant.BITS

  3. https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.BITS

@SpriteOvO SpriteOvO added the F-type_info #![feature(type_info)] label Jan 17, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

The reflection data structures are tied exactly to the implementation
in the compiler. Make sure to also adjust rustc_const_eval/src/const_eval/type_info.rs

cc @oli-obk

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 17, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2026

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@oli-obk
Copy link
Contributor

oli-obk commented Jan 17, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Jan 17, 2026

📌 Commit 27b0279 has been approved by oli-obk

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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 17, 2026
@scottmcm
Copy link
Member

👍

This fits well with rust-lang/compiler-team#693 to me too, where things like count_ones() produce u32, so giving u32 here too makes sense.

jhpratt added a commit to jhpratt/rust that referenced this pull request Jan 18, 2026
Change field `bit_width: usize` to `bits: u32` in type info

Follow-up rust-lang#151123 (comment). Quotes:

@Skgland:
> > I'm not sure whether we should use `usize` or `u64` here to represent the bit width.
>
> My expectation would be `u32` matching the associated `{u,i}N::BITS`[^1][^2][^3] constant that already exists on the integer types.
>
> [^1]: https://doc.rust-lang.org/std/primitive.i8.html#associatedconstant.BITS
> [^2]: https://doc.rust-lang.org/std/primitive.i128.html#associatedconstant.BITS
> [^3]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.BITS

@SpriteOvO:
> I found some [previous discussions](rust-lang#76492 (comment)) regarding the type of `::BITS` constant. And during the stabilization of `::BITS`, the choice of `u32` affected some ecosystem crates (rust-lang#81654), but soon after, these crates all accepted the `u32` type.
>
> So I think it makes sense to keep the type consistent with `::BITS` here. Then I'd also like to change the name from `bit_width` to `bits`, also for consistency.

r? @oli-obk
rust-bors bot pushed a commit that referenced this pull request Jan 18, 2026
Rollup of 9 pull requests

Successful merges:

 - #148769 (Stabilize `alloc_layout_extra`)
 - #149440 (Remove suggestion from importing unstable items on stable channel)
 - #150200 (Add title field to `ice.md` issue template)
 - #150955 (Underscore-prefixed bindings are explicitly allowed to be unused)
 - #151200 (time: Add saturating arithmetic for `SystemTime`)
 - #151235 (Change field `bit_width: usize` to `bits: u32` in type info)
 - #151242 (Port #[needs_allocator] to attribute parser)
 - #151274 (Include a link to `count_ones` in the docs for `uN::count_zeros` [docs only])
 - #151279 (remove trailing periods in built-in attribute gate messages)

r? @ghost
rust-bors bot pushed a commit that referenced this pull request Jan 18, 2026
Rollup of 8 pull requests

Successful merges:

 - #148769 (Stabilize `alloc_layout_extra`)
 - #150200 (Add title field to `ice.md` issue template)
 - #150955 (Underscore-prefixed bindings are explicitly allowed to be unused)
 - #151200 (time: Add saturating arithmetic for `SystemTime`)
 - #151235 (Change field `bit_width: usize` to `bits: u32` in type info)
 - #151242 (Port #[needs_allocator] to attribute parser)
 - #151274 (Include a link to `count_ones` in the docs for `uN::count_zeros` [docs only])
 - #151279 (remove trailing periods in built-in attribute gate messages)

r? @ghost
@rust-bors rust-bors bot merged commit 80db715 into rust-lang:main Jan 18, 2026
11 checks passed
@rustbot rustbot added this to the 1.94.0 milestone Jan 18, 2026
rust-timer added a commit that referenced this pull request Jan 18, 2026
Rollup merge of #151235 - type-info-rename-bits, r=oli-obk

Change field `bit_width: usize` to `bits: u32` in type info

Follow-up #151123 (comment). Quotes:

@Skgland:
> > I'm not sure whether we should use `usize` or `u64` here to represent the bit width.
>
> My expectation would be `u32` matching the associated `{u,i}N::BITS`[^1][^2][^3] constant that already exists on the integer types.
>
> [^1]: https://doc.rust-lang.org/std/primitive.i8.html#associatedconstant.BITS
> [^2]: https://doc.rust-lang.org/std/primitive.i128.html#associatedconstant.BITS
> [^3]: https://doc.rust-lang.org/std/primitive.usize.html#associatedconstant.BITS

@SpriteOvO:
> I found some [previous discussions](#76492 (comment)) regarding the type of `::BITS` constant. And during the stabilization of `::BITS`, the choice of `u32` affected some ecosystem crates (#81654), but soon after, these crates all accepted the `u32` type.
>
> So I think it makes sense to keep the type consistent with `::BITS` here. Then I'd also like to change the name from `bit_width` to `bits`, also for consistency.

r? @oli-obk
@SpriteOvO SpriteOvO deleted the type-info-rename-bits branch January 18, 2026 19:22
@cuviper cuviper modified the milestones: 1.94.0, 1.95.0 Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-type_info #![feature(type_info)] 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. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants