rust/library
bors fcaa6fdfbe Auto merge of #126958 - dtolnay:u32char, r=Mark-Simulacrum
Stabilize const unchecked conversion from u32 to char

Closes https://github.com/rust-lang/rust/issues/89259.

The functions in this PR were left out of the initial set of `feature(const_char_convert)` stabilizations in https://github.com/rust-lang/rust/pull/102470, but have since been unblocked by https://github.com/rust-lang/rust/pull/118979.

If `unsafe { from_u32_unchecked(u) }` is called in const with a value for which `from_u32(u)` returns None, we get the following compile error.

```rust
fn main() {
    let _ = const { unsafe { char::from_u32_unchecked(0xd800) } };
}
```

```console
error[E0080]: it is undefined behavior to use this value
 --> src/main.rs:2:19
  |
2 |     let _ = const { unsafe { char::from_u32_unchecked(0xd800) } };
  |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered 0x0000d800, but expected a valid unicode scalar value (in `0..=0x10FFFF` but not in `0xD800..=0xDFFF`)
  |
  = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior.
  = note: the raw bytes of the constant (size: 4, align: 4) {
              00 d8 00 00                                     │ ....
          }

note: erroneous constant encountered
 --> src/main.rs:2:13
  |
2 |     let _ = const { unsafe { char::from_u32_unchecked(0xd800) } };
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
2024-07-13 18:41:08 +00:00
..
alloc Rollup merge of #124980 - zachs18:rc-allocator, r=Amanieu 2024-07-12 14:37:56 +02:00
backtrace@72265bea21 Update backtrace to 0.3.73 2024-06-06 22:50:45 -07:00
core Auto merge of #126958 - dtolnay:u32char, r=Mark-Simulacrum 2024-07-13 18:41:08 +00:00
panic_abort Stabilise c_unwind 2024-06-19 13:54:51 +01:00
panic_unwind Use the native unwind function in miri where possible 2024-07-01 18:02:40 +00:00
portable-simd wasm64 build with target-feature=+simd128,+atomics 2024-06-23 22:58:30 -07:00
proc_macro Add a hack to prevent proc_macro misopt in CI 2024-06-19 13:54:55 +01:00
profiler_builtins Update cc crate to v1.0.97 2024-05-08 15:06:35 +00:00
rtstartup library: Fix warnings in rtstartup 2024-01-06 01:32:03 +03:00
rustc-std-workspace-alloc Replace libstd, libcore, liballoc in line comments. 2022-12-30 14:00:42 +01:00
rustc-std-workspace-core Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
rustc-std-workspace-std Switch all libraries to the 2021 edition 2021-12-23 19:03:47 +08:00
std std::unix::fs: removing, now useless, layers predating macOs 10.10. 2024-07-13 13:28:55 +01:00
stdarch@df3618d9f3 feat: update stdarch submodule for intrinsics on ARM 2024-05-15 15:38:58 -04:00
sysroot Add flag to sysroot 2024-05-11 14:31:55 +02:00
test Add blank lines after module-level //! comments. 2024-06-20 09:23:20 +10:00
unwind Stabilise c_unwind 2024-06-19 13:54:51 +01:00