about summary refs log tree commit diff
path: root/compiler/rustc_trait_selection/src/traits/auto_trait.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-29 20:25:08 +0000
committerbors <bors@rust-lang.org>2024-03-29 20:25:08 +0000
commitfaae5f1ffe7b7b97e91eee6184807ac7307aafaa (patch)
treea05bb2091da1ce88f1e023d0b9c45ac9360729e2 /compiler/rustc_trait_selection/src/traits/auto_trait.rs
parentaf4a5a13a15fa0c60e06321077ef452f769b42fd (diff)
parent50392ccc5a38f2e4580c67d51836f5add64f7d48 (diff)
downloadrust-faae5f1ffe7b7b97e91eee6184807ac7307aafaa.tar.gz
rust-faae5f1ffe7b7b97e91eee6184807ac7307aafaa.zip
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
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits/auto_trait.rs')
0 files changed, 0 insertions, 0 deletions