Files
rust/library/core/src
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-05-26 15:21:03 +08:00
2025-06-20 17:53:09 +02:00
2025-05-12 15:33:37 +02:00
2025-06-20 17:53:09 +02:00
2025-06-20 20:38:29 +02:00
2025-06-11 18:28:05 +02:00
2025-03-08 12:56:00 +01:00
2025-04-16 18:53:40 -07:00
2025-05-12 15:33:30 +02:00
2024-07-29 08:26:52 +10:00
2025-06-25 17:06:49 -07:00
2025-06-19 16:36:33 -07:00
2025-06-23 08:45:26 +00:00
2024-06-11 15:47:00 +02:00
2025-06-15 22:08:41 +02:00
2025-03-26 14:32:35 -04:00
2024-11-27 15:14:54 +00:00
2025-04-09 12:29:59 +01:00
2025-02-18 09:32:44 -08:00