Jacob Pratt
8951c74e2a
Rollup merge of #138285 - beetrees:repr128-stable, r=traviscross,bjorn3
...
Stabilize `repr128`
## Stabilisation report
The `repr128` feature ([tracking issue](https://github.com/rust-lang/rust/issues/56071 )) allows the use of `#[repr(u128)]` and `#[repr(i128)]` on enums in the same way that other primitive representations such as `#[repr(u64)]` can be used. For example:
```rust
#[repr(u128)]
enum Foo {
One = 1,
Two,
Big = u128::MAX,
}
#[repr(i128)]
enum Bar {
HasThing(u16) = 42,
HasSomethingElse(i64) = u64::MAX as i128 + 1,
HasNothing,
}
```
This is the final part of adding 128-bit integers to Rust ([RFC 1504](https://rust-lang.github.io/rfcs/1504-int128.html )); all other parts of 128-bit integer support were stabilised in #49101 back in 2018.
From a design perspective, `#[repr(u128)]`/`#[repr(i128)]` function like `#[repr(u64)]`/`#[repr(i64)]` but for 128-bit integers instead of 64-bit integers. The only differences are:
- FFI safety: as `u128`/`i128` are not currently considered FFI safe, neither are `#[repr(u128)]`/`#[repr(i128)]` enums (I discovered this wasn't the case while drafting this stabilisation report, so I have submitted #138282 to fix this).
- Debug info: while none of the major debuggers currently support 128-bit integers, as of LLVM 20 `rustc` will emit valid debuginfo for both DWARF and PDB (PDB makes use of the same natvis that is also used for all enums with fields, whereas DWARF has native support).
Tests for `#[repr(u128)]`/`#[repr(i128)]` enums include:
- [ui/enum-discriminant/repr128.rs](385970f0c1/tests/ui/enum-discriminant/repr128.rs ): checks that 128-bit enum discriminants have the correct values.
- [debuginfo/msvc-pretty-enums.rs](385970f0c1/tests/debuginfo/msvc-pretty-enums.rs ): checks the PDB debuginfo is correct.
- [run-make/repr128-dwarf](385970f0c1/tests/run-make/repr128-dwarf/rmake.rs ): checks the DWARF debuginfo is correct.
Stabilising this feature does not require any changes to the Rust Reference as [the documentation on primitive representations](https://doc.rust-lang.org/nightly/reference/type-layout.html#r-layout.repr.primitive.intro ) already includes `u128` and `i128`.
Closes #56071
Closes https://github.com/rust-lang/reference/issues/1368
r? lang
```@rustbot``` label +I-lang-nominated +T-lang
2025-05-29 04:50:46 +02:00
..
2025-03-19 19:45:46 +01:00
2025-05-21 07:24:43 +00:00
2024-05-31 15:56:43 +10:00
2025-04-06 21:41:47 +02:00
2024-12-15 19:01:45 +08:00
2025-04-20 11:18:38 +02:00
2024-10-31 18:20:11 +08:00
2025-02-11 13:41:35 -08:00
2024-12-19 20:36:51 +08:00
2025-04-05 11:44:38 -07:00
2024-05-31 15:56:43 +10:00
2025-05-28 15:14:34 +01:00
2025-04-07 16:53:11 -03:00
2025-04-04 16:13:57 -07:00
2025-02-11 13:41:35 -08:00
2024-12-11 21:34:48 +11:00
2025-05-01 13:49:28 +01:00
2025-05-17 09:49:03 +02:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2024-12-19 20:36:51 +08:00
2025-04-20 11:18:38 +02:00
2024-05-31 15:56:43 +10:00
2025-05-27 11:20:52 -04:00
2024-06-25 19:00:02 +02:00
2025-04-17 19:45:28 +08:00
2025-04-29 10:20:25 +02:00
2025-02-24 09:26:54 +00:00
2025-04-05 04:05:04 +00:00
2025-05-03 10:15:32 +02:00
2025-04-20 12:25:27 +02:00
2024-06-19 13:54:55 +01:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2025-02-24 09:26:54 +00:00
2025-02-18 16:11:41 +01:00
2025-01-30 11:22:46 +01:00
2024-05-31 15:56:43 +10:00
2025-05-17 09:49:03 +02:00
2025-02-16 18:37:50 +01:00
2025-02-16 18:37:50 +01:00
2024-05-31 15:56:43 +10:00
2025-04-16 12:16:40 +02:00
2025-02-11 13:41:35 -08:00
2025-04-07 23:30:55 +02:00
2025-03-17 14:08:09 +00:00
2025-02-10 21:38:44 +01:00
2025-02-11 13:41:35 -08:00
2025-04-12 22:10:17 -07:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-08-10 10:44:24 +08:00
2024-04-11 21:42:35 -04:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-04-11 17:20:08 +00:00
2025-03-21 17:34:45 -07:00
2025-04-10 09:56:37 +02:00
2025-04-10 09:56:37 +02:00
2025-04-11 09:57:21 +02:00
2025-04-10 09:56:37 +02:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-04-16 17:13:50 -04:00
2024-05-31 15:56:43 +10:00
2025-01-31 22:29:08 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-01-26 03:48:27 -05:00
2025-03-17 14:08:09 +00:00
2025-04-05 11:44:38 -07:00
2025-05-17 09:49:03 +02:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-03-06 21:38:39 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-04-03 21:59:43 +08:00
2024-07-25 15:14:42 -04:00
2024-05-31 15:56:43 +10:00
2024-08-07 14:08:34 +02:00
2025-02-14 18:55:50 +00:00
2025-02-17 16:36:14 -08:00
2025-03-06 22:29:05 +08:00
2024-10-23 04:42:03 +02:00
2024-04-24 13:12:33 +01:00
2025-03-28 09:19:57 +00:00
2025-05-04 18:11:48 -04:00
2024-09-21 01:07:00 -04:00
2024-06-04 01:30:51 -07:00
2024-05-31 15:56:43 +10:00
2025-04-10 09:56:37 +02:00
2025-03-17 14:08:09 +00:00
2025-02-03 10:39:32 -05:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-03-28 09:19:57 +00:00
2025-02-11 13:41:35 -08:00
2025-04-10 09:56:37 +02:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-10-11 08:43:27 +11:00
2024-06-05 15:40:11 +00:00
2025-04-07 09:36:56 +02:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-04-06 21:41:47 +02:00
2025-04-06 21:41:47 +02:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-03-28 09:19:57 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-04-04 16:13:57 -07:00
2024-06-23 00:40:43 -07:00
2025-02-03 10:39:32 -05:00
2024-05-31 15:56:43 +10:00
2025-05-17 06:42:46 +02:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-01-21 06:59:15 -07:00
2024-07-14 13:48:29 +03:00
2025-02-19 15:15:29 +01:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-19 08:41:19 +01:00
2025-04-10 09:56:37 +02:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-04-10 09:56:37 +02:00
2025-03-06 22:29:05 +08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-04-16 14:48:20 +02:00
2025-02-11 13:41:35 -08:00
2024-09-18 13:53:31 -07:00
2025-03-17 14:08:09 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-28 09:19:57 +00:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-07-14 13:48:29 +03:00
2025-02-11 13:41:35 -08:00
2025-03-12 00:56:43 -07:00
2025-02-11 13:41:35 -08:00
2024-12-10 01:29:43 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-01-10 22:53:54 +01:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-04-20 11:18:38 +02:00
2024-09-21 01:07:00 -04:00
2024-05-31 15:56:43 +10:00
2025-02-24 09:26:54 +00:00
2024-04-04 21:59:08 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2024-07-14 13:48:29 +03:00
2025-02-11 13:41:35 -08:00
2025-01-23 17:19:53 +00:00
2025-02-11 13:41:35 -08:00
2025-05-27 11:20:52 -04:00
2025-02-23 21:23:36 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-06 10:50:23 +00:00
2025-02-11 13:41:35 -08:00
2024-06-14 13:31:46 +10:00
2024-06-14 13:31:46 +10:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2025-02-19 11:32:32 +01:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-03-12 22:39:43 -07:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-04-20 11:34:56 +02:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-02-11 13:41:35 -08:00
2025-04-10 21:07:09 -07:00
2025-02-11 13:41:35 -08:00
2025-03-02 18:53:49 +00:00
2025-03-19 19:45:46 +01:00
2025-02-11 13:41:35 -08:00
2025-02-12 23:01:27 -08:00
2025-02-14 22:24:27 -08:00
2025-03-31 22:38:53 +09:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-13 21:26:48 -08:00
2025-02-11 13:41:35 -08:00
2025-03-30 12:45:04 -04:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-24 09:26:54 +00:00
2024-05-31 15:56:43 +10:00
2024-05-31 15:56:43 +10:00
2024-08-07 00:41:48 -04:00
2025-02-24 09:26:54 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2024-05-31 15:56:43 +10:00
2025-04-09 13:06:10 +03:00
2025-04-09 09:09:37 -07:00
2025-04-09 10:44:49 -07:00
2025-03-06 19:56:21 +00:00
2025-02-24 09:26:54 +00:00
2025-02-06 18:21:13 +03:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-19 11:36:52 -08:00
2025-04-10 09:56:37 +02:00
2024-05-31 15:56:43 +10:00
2024-10-19 13:09:21 +00:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-02-25 17:46:05 -05:00
2025-03-28 09:19:57 +00:00
2025-03-19 23:57:49 -04:00
2025-02-19 11:36:52 -08:00
2024-06-19 13:54:55 +01:00
2024-06-19 13:54:55 +01:00
2024-06-19 13:54:55 +01:00
2024-09-18 13:53:31 -07:00
2024-09-18 13:53:31 -07:00
2025-02-11 13:41:35 -08:00
2025-04-05 11:44:38 -07:00
2025-02-11 13:41:35 -08:00
2025-03-17 14:08:09 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-03-17 14:08:09 +00:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-27 12:58:18 +08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-11 13:41:35 -08:00
2025-02-06 23:44:23 +01:00
2025-01-28 19:10:26 +03:00
2025-02-11 13:41:35 -08:00
2024-09-09 19:39:43 -07:00