rust/library
Christopher Durham b92cd1a32c
Clarify str::from_utf8_unchecked's invariants
Specifically, make it clear that it is immediately UB to pass ill-formed UTF-8 into the function. The previous wording left space to interpret that the UB only occurred when calling another function, which "assumes that `&str`s are valid UTF-8."

This does not change whether str being UTF-8 is a safety or a validity invariant. (As per previous discussion, it is a safety invariant, not a validity invariant.) It just makes it clear that valid UTF-8 is a precondition of str::from_utf8_unchecked, and that emitting an Abstract Machine fault (e.g. UB or a sanitizer error) on invalid UTF-8 is a valid thing to do.

If user code wants to create an unsafe `&str` pointing to ill-formed UTF-8, it must be done via transmutes. Also, just, don't.
2022-04-10 15:04:57 -05:00
..
alloc Rollup merge of #95817 - oconnor663:doc_comment2, r=yaahc 2022-04-09 18:26:29 +02:00
backtrace@b02ed04a7e
core Clarify str::from_utf8_unchecked's invariants 2022-04-10 15:04:57 -05:00
panic_abort fix some unused constant warning on some Windows targets 2022-04-08 08:36:56 -04:00
panic_unwind library/panic_unwind: Define UNWIND_DATA_REG for m68k 2022-02-12 20:19:06 +00:00
portable-simd Sync portable-simd to rust-lang/portable-simd@72df4c4505 2022-03-12 16:09:37 -08:00
proc_macro Rollup merge of #95308 - bjorn3:more_stable_proc_macro, r=Mark-Simulacrum 2022-04-09 12:52:02 +02:00
profiler_builtins
rtstartup
rustc-std-workspace-alloc
rustc-std-workspace-core
rustc-std-workspace-std
std Auto merge of #95621 - saethlin:remove-mpsc-transmute, r=RalfJung 2022-04-10 08:57:32 +00:00
stdarch@bcbe010614 Update stdarch submodule 2022-03-02 20:06:46 +01:00
test Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrum 2022-04-07 07:34:04 +00:00
unwind Auto merge of #95678 - pietroalbini:pa-1.62.0-bootstrap, r=Mark-Simulacrum 2022-04-07 07:34:04 +00:00