Files
rust/tests/ui
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-11 15:30:15 +01:00
2025-05-21 07:24:43 +00:00
2025-06-11 17:49:03 +05:00
2025-06-11 20:51:49 +05:00
2025-06-18 10:20:43 +02:00
2025-06-08 01:14:05 +05:00
2025-06-16 07:30:09 -04:00
2025-06-06 20:52:34 +00:00
2025-06-26 03:43:01 +00:00
2025-05-31 19:49:19 +05:00
2025-06-11 20:51:49 +05:00
2025-03-11 20:26:10 -07:00
2025-06-13 01:16:36 +02:00
2025-06-03 11:45:58 +02:00
2025-06-08 01:14:05 +05:00
2025-06-18 10:20:43 +02:00
2025-06-18 10:20:43 +02:00
2025-06-27 12:07:52 +07:00
2025-06-03 07:38:06 +05:00
2025-06-11 15:30:15 +01:00
2025-06-11 15:30:15 +01:00
2025-06-24 23:00:31 +02:00
2025-06-08 11:25:09 +05:00
2025-06-18 10:20:43 +02:00
2025-06-13 09:20:48 +02: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-08 11:25:09 +05:00
2025-03-27 14:11:11 +01:00
2025-06-18 10:20:43 +02:00
2025-04-25 20:50:57 +09:00
2025-05-05 21:09:31 +02:00
2025-06-08 03:44:44 +05:00
2025-06-13 01:16:36 +02:00
2025-06-18 10:20:43 +02:00
2025-04-03 21:41:58 +00:00
2025-02-04 21:42:43 +05:30
2025-04-03 21:41:58 +00:00
2025-05-07 21:51:41 +05:00
2025-04-04 16:32:18 +02:00