Commit graph

269 commits

Author SHA1 Message Date
Nikolai Kuklin
689e8c2099
Add documentation note about signed overflow direction 2026-02-05 16:34:54 +01:00
ltdk
28feae0c87 Move bigint helper tracking issues 2026-02-02 18:45:26 -05:00
Jonathan Brouwer
13633c5bdc
Rollup merge of #150011 - scottmcm:more-unbounded-shift-docs, r=Mark-Simulacrum
Add more `unbounded_sh[lr]` examples

Inspired by rust-lang/rust#149837, which added more stuff to `wrapping_sh[lr]`, including a cross-reference to these methods.
2025-12-28 22:52:33 +01:00
Boxy Uwu
90a33f69f4 replace version placeholder 2025-12-19 15:04:30 -08:00
Scott McMurray
242e58ea59 Add more unbounded_sh[lr] examples 2025-12-14 21:17:46 -08:00
Matthias Krüger
a8460d0cf2
Rollup merge of #149837 - scottmcm:wrapping-shift-docs, r=workingjubilee
Update `wrapping_sh[lr]` docs and examples

Inspired by [#general > `Source` link for `core` items is often inscrutable @ 💬][zulip-thread] I wanted to add some more examples of the actual wrapping as well as update the documentation to emphasize that the behaviour is unusual.

In particular, now that `unbounded_sh[lr]` is stable, point people trying to avoid panics to that instead, since it behaves less weirdly.

[zulip-thread]: https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/.60Source.60.20link.20for.20.60core.60.20items.20is.20often.20inscrutable/near/562774474
2025-12-14 20:04:55 +01:00
Scott McMurray
ff43366dc2 Update wrapping_sh[lr] docs and examples 2025-12-10 00:23:11 -08:00
Stuart Cook
ac729a4b18
Rollup merge of #149207 - EFanZh:add-ilog10-result-range-hints, r=Mark-Simulacrum
Add `ilog10` result range hints

This PR adds hints that the return value of `T::ilog10` will never exceed `T::MAX.ilog10()`.

This works because `ilog10` is a monotonically nondecreasing function, the maximum return value is reached at the max input value.
2025-12-08 11:46:23 +11:00
Stuart Cook
80b4c44f62
Rollup merge of #148935 - Wilfred:fix_remainder_docs, r=Mark-Simulacrum
Fix division syntax in doc comments

`mod` is a keyword in Rust, and since we're talking about remainders we should be using division syntax here.
2025-12-08 11:46:22 +11:00
Matthias Krüger
9a967de929
Rollup merge of #148690 - IntegralPilot:clamp-mag, r=joboet
Implement `clamp_magnitude` method for primitive floats & signed integers

Tracking issue rust-lang/rust#148519
ACP https://github.com/rust-lang/libs-team/issues/686
2025-12-01 17:55:05 +01:00
MolecularPilot
ae7fa32e5b Implement clamp_magnitude for floats & signed integers
Added feature gate, documentation and tests also.
2025-12-01 17:04:25 +11:00
EFanZh
4046385d60 Add ilog10 result range hints 2025-11-29 09:52:19 +08:00
Stuart Cook
549c577c2a
Rollup merge of #149087 - nxsaken:unchecked_neg_shifts_stabilize, r=Amanieu
Stabilize `unchecked_neg` and `unchecked_shifts`

Features: `unchecked_neg`, `unchecked_shifts`
Tracking issue: rust-lang/rust#85122

r? `@Amanieu`
2025-11-28 15:30:43 +11:00
Kornel
3faad7cc41
Suggest _bytes versions of endian-converting methods 2025-11-25 00:57:50 +00:00
nxsaken
47153b5276 Stabilize unchecked_neg and unchecked_shifts 2025-11-19 13:19:22 +04:00
bors
89fe96197d Auto merge of #148478 - RalfJung:rotating-funnel, r=Mark-Simulacrum
use funnel shift as fallback impl for rotating shifts

That lets us remove this gnarly implementation from Miri and const-eval.

However, `rotate_left`/`rotate_right` are stable as const fn, so to do this we have to `rustc_allow_const_fn_unstable` a bunch of const trait stuff. Is that a bad idea? Cc `@oli-obk` `@fee1-dead`
2025-11-17 04:36:16 +00:00
Wilfred Hughes
95b5bbac7c Fix division syntax in doc comments
`mod` is a keyword in Rust, and since we're talking about remainders
we should be using division syntax here.
2025-11-16 00:33:36 +00:00
bors
54f417673c Auto merge of #148526 - reddevilmidzy:docs, r=Mark-Simulacrum
Expand pow docs with special-case tests

resolve: rust-lang/rust#148316

Files changed:

* library/std/src/num: f32.rs, f64.rs,
  * powi
  * powf
* library/std/src/num: f16.rs, f128.rs
  * powf
* library/core/src/num: f16.rs, f128.rs
  * powi
* library/core/src/num: int_macros.rs, uint_macros.rs
  * checked_pow
  * strict_pow
  * saturating_pow
  * wrapping_pow
  * overflowing_pow
  * pow
2025-11-15 22:01:14 +00:00
bors
2636cb4c13 Auto merge of #148818 - Zalathar:rollup-4vujcg0, r=Zalathar
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#148694 (std: support `RwLock` and thread parking on TEEOS)
 - rust-lang/rust#148712 (Port `cfg_select!` to the new attribute parsing system)
 - rust-lang/rust#148760 (rustc_target: hide TargetOptions::vendor)
 - rust-lang/rust#148771 (IAT: Reinstate early bailout)
 - rust-lang/rust#148775 (Fix a typo in the documentation for the strict_shr function)
 - rust-lang/rust#148779 (Implement DynSend and DynSync for std::panic::Location.)
 - rust-lang/rust#148781 ([rustdoc] Remove unneeded `allow(rustc::potential_query_instability)`)
 - rust-lang/rust#148783 (add test for assoc type norm wf check)
 - rust-lang/rust#148785 (Replace `master` branch references with `main`)
 - rust-lang/rust#148791 (fix "is_closure_like" doc comment)
 - rust-lang/rust#148792 (Prefer to use file.stable_id over file.name from source map)
 - rust-lang/rust#148805 (rustc-dev-guide subtree update)
 - rust-lang/rust#148807 (Document (and test) a problem with `Clone`/`Copy` deriving.)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-11 13:30:50 +00:00
Stuart Cook
0c615a1adb
Rollup merge of #148775 - reddevilmidzy:fix-typo, r=joboet
Fix a typo in the documentation for the strict_shr function

fix: rust-lang/rust#148761
2025-11-11 21:11:51 +11:00
Stuart Cook
044c079b15
Rollup merge of #147771 - nxsaken:div_shlr_exact, r=dtolnay
Rename `*exact_{div,shr,shl}` to `*{div,shr,shl}_exact`

Related to rust-lang/rust#144336 and rust-lang/rust#139911, see https://github.com/rust-lang/rust/issues/139911#issuecomment-3406807537. I haven't touched the `exact_div`, `exact_udiv` and `exact_sdiv` intrinsics. Let me know if I should.
2025-11-11 21:09:34 +11:00
reddevilmidzy
3d44acac27 Fix a typo in the documentation for the strict_shr function 2025-11-10 15:22:08 +09:00
reddevilmidzy
5d595cf8ba Expand pow docs with special-case tests 2025-11-10 14:56:05 +09:00
Shun Sakai
d956fa10ce style: Update doctests for highest_one and lowest_one
Use binary literals instead of hex literals.
2025-11-06 20:07:47 +09:00
Ralf Jung
434cb5e700 document behavior of rotations for n >= BITS 2025-11-06 08:02:10 +01:00
nxsaken
f590ae6543 Rename {u,i}N::*exact_sh{l,r} to *sh{l,r}_exact 2025-11-02 16:35:31 +04:00
nxsaken
b76267672f Rename {i,u}N::*exact_div to *div_exact 2025-11-02 16:34:36 +04:00
bors
73e6c9ebd9 Auto merge of #147784 - nxsaken:div_exact_return_option, r=dtolnay
Return `Option` from `exact_div` and inherit overflow checks

According to https://github.com/rust-lang/rust/issues/139911#issuecomment-3404056127, `exact_div` should return `Option::None` if `self % rhs != 0`, panic if `rhs == 0`, and handle overflow conditionally (panic in debug, wrap in release).

rust-lang/rust#147771 should rename `exact_div` to `div_exact`.
2025-11-02 08:05:11 +00:00
Shun Sakai
c5b30c3b97 docs: Fix argument names for carrying_mul_add 2025-10-31 14:42:03 +09:00
nxsaken
e834a2e55f Remove whitespace 2025-10-16 22:41:45 +04:00
nxsaken
298d825cbb Return Option from exact_div and inherit overflow checks 2025-10-16 22:03:50 +04:00
Mark Rousskov
4e9716fbc5 Update CURRENT_RUSTC_VERSION post-bump 2025-09-26 18:41:32 -04:00
Ralf Jung
7d0012914e assert_unsafe_precondition: fix some incorrect check_language_ub 2025-09-22 09:28:38 +02:00
Trevor Gross
1a6cfacd8e
Rollup merge of #144342 - Qelxiros:exact-bitshifts, r=tgross35
add exact bitshifts

Tracking issue: rust-lang/rust#144336

cc ```@lolbinarycat```
2025-09-05 01:53:20 -04:00
Jeremy Smart
cefa74f1f4
add exact bitshifts 2025-09-02 23:28:09 -04:00
AudaciousAxiom
5a9e2e4aa8 docs(std): add missing closing code block fences in doc comments 2025-09-02 22:11:29 +02:00
Jacob Pratt
5a0c9386a2
Rollup merge of #145381 - Gnurou:int_lowest_highest_one, r=jhpratt
Implement feature `int_lowest_highest_one` for integer and NonZero types

Tracking issue: rust-lang/rust#145203

Implement the accepted ACP rust-lang/rust#145203 for methods that find the index of the least significant (lowest) and most significant (highest) set bit in an integer for signed, unsigned, and NonZero types.

Also add unit tests for all these types.
2025-08-20 00:45:56 -04:00
许杰友 Jieyou Xu (Joe)
0b80d406ce
Rollup merge of #144767 - tgross35:doc-grammar, r=ibraheemdev
Correct some grammar in integer documentation

Update "between" to "among" (more than two items), connect the "which" dependent clause to the independent part, and remove the redundant "here".
2025-08-19 19:42:04 +08:00
Alexandre Courbot
73d3d28bed Implement feature int_lowest_highest_one for integer and NonZero types
Implement the accepted ACP for methods that find the index of the least
significant (lowest) and most significant (highest) set bit in an
integer for signed, unsigned, and NonZero types.

Also add unit tests for all these types.
2025-08-18 18:59:44 +09:00
Stuart Cook
622b21e80b
Rollup merge of #144682 - nxsaken:strict_overflow_ops, r=Mark-Simulacrum
Stabilize `strict_overflow_ops`

Closes rust-lang/rust#118260
2025-08-07 20:49:47 +10:00
okaneco
eee6f804a9 Renamed isolate_most_least_significant_one functions
libs-api has agreed to rename these functions to
`isolate_highest_one`/`isolate_lowest_one`
2025-08-05 16:37:04 -04:00
Trevor Gross
ad61b3113c Correct some grammar in integer documentation
Update "between" to "among" (more than two items), connect the "which"
dependent clause to the independent part, and remove the redundant
"here".
2025-07-31 22:53:27 -05:00
Nurzhan Sakén
3ff3a1ee00 Stabilize strict_overflow_ops 2025-07-30 23:39:35 +04:00
Tshepang Mbambo
5babf24657 integer docs: remove extraneous text
"Basic usage" implies there is an example that shows advanced usage,
but these APIs are extra simple.
2025-06-20 20:38:29 +02:00
Shun Sakai
8584c7c6a4 chore(doctest): Remove redundant blank lines 2025-06-12 16:29:09 +09:00
Jubilee
a1d70ed5b0
Rollup merge of #141237 - Qelxiros:139911-exact-div, r=workingjubilee
Implement ((un)checked_)exact_div methods for integers

tracking issue: #139911

I see that there might still be some bikeshedding to be done, so if people want changes to this implementation, I'm happy to make those. I did also see that there was a previous attempt at this PR (#116632), but I'm not sure why it got closed.
2025-05-30 13:52:25 -07:00
Ben Kimock
e36dc78edd Add some track_caller info to precondition panics 2025-05-21 09:10:06 -04:00
Jeremy Smart
90ebad3f49
add exact_div functions 2025-05-18 23:49:28 -04:00
Pietro Albini
2ce08ca5d6
update cfg(bootstrap) 2025-05-12 15:33:37 +02:00
bendn
c8c074288a
Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc 2025-04-24 13:14:36 +07:00