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-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-06-11 20:51:49 +05:00
2025-06-13 01:16:36 +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-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-06-18 10:20:43 +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