rust/library/alloc/src
bors faae5f1ffe Auto merge of #122520 - scottmcm:stabilize_unchecked_math_basics, r=jhpratt
Stabilize `unchecked_{add,sub,mul}`

Tracking issue: #85122

I think we might as well just stabilize these basic three.  They're the ones that have `nuw`/`nsw` flags in LLVM.

Notably, this doesn't include the potentially-more-complex or -more-situational things like `unchecked_neg` or `unchecked_shr` that are under different feature flags.

To quote Ralf https://github.com/rust-lang/rust/issues/85122#issuecomment-1681669646,

> Are there any objections to stabilizing at least `unchecked_{add,sub,mul}`? For those there shouldn't be any surprises about what their safety requirements are.

*Semantially* these are [already available on stable, even in `const`, via](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=bdb1ff889b61950897f1e9f56d0c9a36) `checked_*`+`unreachable_unchecked`.  So IMHO we might as well just let people write them directly, rather than try to go through a `let Some(x) = x.checked_add(y) else { unsafe { hint::unreachable_unchecked() }};` dance.

I added additional text to each method to attempt to better describe the behaviour and encourage `wrapping_*` instead.

r? rust-lang/libs-api
2024-03-29 20:25:08 +00:00
..
alloc run alloc benchmarks in Miri and fix UB 2022-11-07 10:34:04 +01:00
boxed library: use addr_of! 2024-02-24 16:02:17 +03:00
collections lib: fix some unnecessary_cast clippy lint 2024-03-25 23:19:40 +03:00
ffi lib: fix some unnecessary_cast clippy lint 2024-03-25 23:19:40 +03:00
raw_vec try_with_capacity for RawVec 2024-03-01 18:20:48 +00:00
rc remove redundant imports 2023-12-10 10:56:22 +08:00
slice ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
sync Fix some Arc allocator leaks 2024-01-28 18:33:34 +01:00
testing Share testing utilities with non-btree test cases 2022-05-02 10:07:50 +02:00
vec Rollup merge of #123107 - avandesa:vec_pop_if, r=joboet 2024-03-27 05:21:18 +01:00
alloc.rs step cfgs 2024-03-20 08:49:13 -04:00
borrow.rs Add more diagnostic items for clippy 2023-10-05 18:21:47 -04:00
boxed.rs Require DerefPure for patterns 2024-03-25 19:39:45 -04:00
fmt.rs docs: use correct link, use secondary example 2024-02-12 20:17:47 -05:00
lib.rs Auto merge of #122520 - scottmcm:stabilize_unchecked_math_basics, r=jhpratt 2024-03-29 20:25:08 +00:00
macros.rs Update doc for alloc::format! and core::concat! 2023-09-06 15:11:21 +02:00
raw_vec.rs Less generic code for Vec allocations 2024-03-27 15:27:47 +00:00
rc.rs Require DerefPure for patterns 2024-03-25 19:39:45 -04:00
slice.rs lib: fix some unnecessary_cast clippy lint 2024-03-25 23:19:40 +03:00
str.rs Export core::str::from_raw_parts{,_mut} into alloc::str and std::str 2024-01-25 18:11:54 -08:00
string.rs Rollup merge of #122835 - compiler-errors:deref-pure, r=Nadrieril 2024-03-26 21:23:48 +01:00
sync.rs Require DerefPure for patterns 2024-03-25 19:39:45 -04:00
task.rs lib: fix some unnecessary_cast clippy lint 2024-03-25 23:19:40 +03:00
tests.rs remove redundant imports 2023-12-10 10:56:22 +08:00