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-06-25 22:14:56 +02:00
2025-06-24 09:06:49 +00:00
2025-06-23 21:30:56 +03:00
2025-06-11 15:30:15 +01:00
2025-06-23 12:22:57 +02:00
2025-06-26 15:42:57 +02:00
2025-06-24 18:59:42 +00:00
2025-06-22 10:58:25 +02:00
2025-06-27 07:51:38 +00:00
2025-06-27 08:58:26 +02:00
2025-06-12 03:14:51 +02:00
2025-06-22 10:58:25 +02:00
2025-06-26 15:47:22 +02:00
2025-06-11 17:49:03 +05:00
2025-06-13 18:10:06 +02:00
2025-06-24 18:59:42 +00:00
2025-06-11 20:51:49 +05:00
2025-06-19 10:50:03 +09:00
2025-06-22 10:58:25 +02:00
2025-06-25 00:52:11 -07:00
2025-06-16 23:04:33 +00:00
2025-06-18 10:20:43 +02:00
2025-06-24 17:48:09 +00:00
2025-06-07 13:42:30 +02:00
2025-06-23 21:30:56 +03:00
2025-06-24 18:59:42 +00:00
2025-06-27 22:13:07 +02:00
2025-06-07 13:42:30 +02:00
2025-06-27 22:13:06 +02:00
2025-06-25 17:02:26 +00:00
2025-06-08 01:14:05 +05:00
2025-06-16 23:04:33 +00:00
2025-06-25 22:14:54 +02:00
2025-06-25 22:14:54 +02:00
2025-06-09 16:28:58 +02:00
2025-06-16 07:30:09 -04:00
2025-06-27 07:51:38 +00:00
2025-06-12 03:14:52 +02:00
2025-06-08 06:18:38 -07:00
2025-06-24 18:59:42 +00:00
2025-06-15 23:51:55 +02:00
2025-06-12 12:26:27 +02:00
2025-06-07 13:42:30 +02:00
2025-06-27 17:03:48 +02:00
2025-06-06 20:52:34 +00:00
2025-06-22 10:58:25 +02:00
2025-06-07 13:42:30 +02:00
2025-06-26 03:43:01 +00:00
2025-06-16 23:04:36 +00:00
2025-06-24 09:06:49 +00:00
2025-06-25 17:02:26 +00:00
2025-06-22 10:58:25 +02:00
2025-06-27 07:51:38 +00:00
2025-06-17 23:22:51 +02:00
2025-06-22 10:58:25 +02:00
2025-06-26 15:42:57 +02:00
2025-06-27 07:51:38 +00:00
2025-06-06 16:27:16 -04:00
2025-06-22 17:08:54 +02:00
2025-06-23 21:30:56 +03:00
2025-06-27 22:13:00 +02:00
2025-06-25 17:02:26 +00:00
2025-06-11 20:51:49 +05:00
2025-06-26 15:47:22 +02:00
2025-06-07 13:42:30 +02:00
2025-06-10 08:41:23 +00:00
2025-06-12 17:50:25 +02:00
2025-06-17 23:22:51 +02:00
2025-06-16 23:04:33 +00:00
2025-06-27 17:03:48 +02:00
2025-06-13 01:16:36 +02:00
2025-06-12 19:01:19 +08:00
2025-06-18 18:06:49 +02:00
2025-06-16 23:04:35 +00:00
2025-06-07 13:42:30 +02:00
2025-06-24 18:59:42 +00:00
2025-06-07 13:42:30 +02:00
2025-06-23 09:40:00 -07:00
2025-06-08 01:14:05 +05:00
2025-06-27 08:58:26 +02:00
2025-06-18 10:20:43 +02:00
2025-06-23 20:43:04 +02:00
2025-06-18 10:20:43 +02:00
2025-06-27 22:13:00 +02:00
2025-06-17 23:19:31 +02:00
2025-06-24 18:59:42 +00:00
2025-06-28 10:25:00 +00:00
2025-06-23 21:30:56 +03:00
2025-06-27 12:07:52 +07:00
2025-06-25 01:12:15 +07:00
2025-06-24 18:44:41 +00:00
2025-06-25 22:14:54 +02:00
2025-06-24 18:59:42 +00:00
2025-06-24 09:06:49 +00:00
2025-06-18 18:06:49 +02:00
2025-06-16 23:04:35 +00:00
2025-06-22 10:58:25 +02:00
2025-06-16 23:04:33 +00:00
2025-06-27 22:13:01 +02:00
2025-06-17 12:24:44 -07:00
2025-06-27 22:13:00 +02:00
2025-06-11 15:30:15 +01:00
2025-06-15 10:31:11 +08:00
2025-06-16 12:43:36 -07:00
2025-06-16 23:04:33 +00:00
2025-06-17 01:36:54 +09:00
2025-06-20 19:31:53 +02:00
2025-06-27 14:39:35 +02:00
2025-06-24 18:59:42 +00:00
2025-06-11 15:30:15 +01:00
2025-06-20 13:36:00 -04:00
2025-06-12 03:14:52 +02:00
2025-06-24 23:00:31 +02:00
2025-06-08 11:25:09 +05:00
2025-06-24 23:32:09 +08:00
2025-06-23 21:30:56 +03:00
2025-06-27 07:51:38 +00:00
2025-06-18 18:06:49 +02:00
2025-06-18 10:20:43 +02:00
2025-06-27 17:01:47 +00:00
2025-06-22 10:58:25 +02:00
2025-06-26 13:46:45 +00:00
2025-06-17 23:22:51 +02:00
2025-06-16 23:04:33 +00:00
2025-06-13 09:20:48 +02:00
2025-06-27 22:13:06 +02:00
2025-06-25 13:08:51 -07:00
2025-06-13 01:16:36 +02:00
2025-06-17 07:27:58 +08:00
2025-06-26 18:11:14 +00:00
2025-06-27 07:51:38 +00:00
2025-06-16 23:04:35 +00:00
2025-06-16 23:04:33 +00:00
2025-06-19 10:50:03 +09:00
2025-06-08 11:25:09 +05:00
2025-06-23 20:43:04 +02:00
2025-06-09 11:44:24 +02:00
2025-06-10 08:41:23 +00:00
2025-06-27 22:13:00 +02:00
2025-06-09 14:08:12 +00:00
2025-06-07 13:42:30 +02:00
2025-06-18 10:20:43 +02:00
2025-06-23 21:30:56 +03:00
2025-06-25 17:02:26 +00:00
2025-06-27 07:51:38 +00:00
2025-06-08 03:44:44 +05:00
2025-06-24 16:21:26 +00:00
2025-06-27 22:13:00 +02:00
2025-06-10 08:41:23 +00:00
2025-06-13 01:16:36 +02:00
2025-06-24 23:32:09 +08:00
2025-06-18 10:20:43 +02:00
2025-06-09 19:55:00 +00:00
2025-06-13 13:54:06 +00:00
2025-06-23 21:30:56 +03:00
2025-06-06 19:53:12 +00:00
2025-06-12 07:35:05 +02:00
2025-06-25 00:52:11 -07:00
2025-06-25 22:14:56 +02:00
2025-06-06 19:53:12 +00:00
2025-06-18 10:20:43 +02:00