bors
b63223c152
Auto merge of #141759 - 1c3t3a:discriminants-query, r=saethlin
...
Insert checks for enum discriminants when debug assertions are enabled
Similar to the existing null-pointer and alignment checks, this checks for valid enum discriminants on creation of enums through unsafe transmutes. Essentially this sanitizes patterns like the following:
```rust
let val: MyEnum = unsafe { std::mem::transmute<u32, MyEnum>(42) };
```
An extension of this check will be done in a follow-up that explicitly sanitizes for extern enum values that come into Rust from e.g. C/C++.
This check is similar to Miri's capabilities of checking for valid construction of enum values.
This PR is inspired by saethlin@'s PR
https://github.com/rust-lang/rust/pull/104862 . Thank you so much for keeping this code up and the detailed comments!
I also pair-programmed large parts of this together with vabr-g@.
r? `@saethlin`
2025-06-28 10:25:00 +00:00
..
2025-04-25 12:16:40 +00:00
2024-05-04 19:27:27 +00:00
2025-06-27 09:37:36 +00:00
2025-05-04 18:27:45 +03:00
2024-10-17 00:16:19 +08:00
2025-02-08 22:28:21 +00:00
2025-05-04 18:27:45 +03:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2025-02-24 09:26:54 +00:00
2024-10-31 13:12:22 +08:00
2024-04-04 00:10:52 -04:00
2024-02-16 20:02:50 +00:00
2024-02-08 07:39:49 +00:00
2024-02-08 07:39:49 +00:00
2024-05-25 00:44:47 -07:00
2024-09-24 08:56:41 +00:00
2024-11-12 13:28:05 +00:00
2024-11-12 13:28:05 +00:00
2024-11-12 13:28:05 +00:00
2025-04-08 23:06:31 +03:00
2024-11-12 13:28:05 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2023-12-07 23:00:46 -05:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-07-21 21:42:10 +08:00
2024-07-21 21:42:10 +08:00
2024-02-16 20:02:50 +00:00
2025-03-27 17:45:02 +00:00
2024-12-06 16:42:09 -05:00
2024-02-11 19:17:42 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-12-13 00:04:56 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2025-03-30 01:32:21 +03:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-22 23:30:31 -07:00
2024-06-22 23:30:31 -07:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2023-11-24 19:15:52 +01:00
2025-04-18 15:57:29 +02:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-24 22:21:15 +00:00
2025-04-10 09:56:37 +02:00
2024-02-16 20:02:50 +00:00
2025-02-10 20:21:39 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2025-02-14 00:44:10 -08:00
2025-01-24 01:19:50 +00:00
2025-01-24 01:19:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2025-01-23 20:51:29 +08:00
2025-01-23 20:51:29 +08:00
2024-02-16 20:02:50 +00:00
2025-01-23 20:51:29 +08:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-03 13:24:44 +10:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2025-01-23 20:51:29 +08:00
2025-01-23 20:51:29 +08:00
2025-01-23 20:51:29 +08:00
2024-09-13 14:10:56 +03:00
2024-02-16 20:02:50 +00:00
2025-06-04 10:40:04 -04:00
2024-02-16 20:02:50 +00:00
2025-01-23 20:51:29 +08:00
2025-01-23 20:51:29 +08:00
2025-01-23 20:51:29 +08:00
2025-04-18 14:21:14 +02:00
2024-02-16 20:02:50 +00:00
2025-05-13 16:22:52 +02:00
2024-05-02 19:42:31 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-08-18 19:46:53 +02:00
2024-08-18 19:46:53 +02:00
2025-06-12 07:35:05 +02:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-03-24 10:51:23 +01:00
2024-03-24 10:51:23 +01:00
2024-03-24 10:51:23 +01:00
2024-03-24 10:51:23 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-29 10:42:31 +00:00
2024-06-03 13:24:44 +10:00
2024-02-16 20:02:50 +00:00
2024-05-04 19:26:51 +00:00
2024-02-16 20:02:50 +00:00
2025-06-15 21:12:17 +00:00
2025-06-15 21:12:17 +00:00
2024-02-16 20:02:50 +00:00
2025-03-26 11:35:34 +01:00