9607 Commits

Author SHA1 Message Date
Marco Cavenati
400e687598 Bump unicode_data to version 17.0.0 2025-09-09 09:03:52 +02:00
Stuart Cook
fde2ef616d Rollup merge of #146326 - cyrgani:int-module-1, r=jhpratt
simplify the declaration of the legacy integer modules (`std::u32` etc.)

This PR removes some duplicated code from the declaration of the legacy integer modules by expanding the macro which is already used to generate `MIN` and `MAX` to now generate the whole module.
This would also make the remaining steps listed in rust-lang/rust#68490 such as fully deprecating the modules or placing `#[doc(hidden)]` on them easier.
2025-09-09 14:35:06 +10:00
Stuart Cook
915f9ff160 Rollup merge of #146324 - RalfJung:no-ptr-fragment, r=oli-obk
const-eval: disable pointer fragment support

This fixes https://github.com/rust-lang/rust/issues/146291 by disabling pointer fragment support for const-eval. I want to properly fix this eventually, but won't get to it in the next few weeks, so this is an emergency patch to prevent the buggy implementation from landing on stable. The beta cutoff is on Sep 12th so if this PR lands after that, we'll need a backport.
2025-09-09 14:35:05 +10:00
Stuart Cook
b543b1444b Rollup merge of #146314 - cyrgani:hide-fmt-args-nl, r=GuillaumeGomez
mark `format_args_nl!` as `#[doc(hidden)]`

The `#[unstable]` attribute of the macro already says:

> `format_args_nl` is only for internal language use and is subject to change

It does seem plausible to hide it from the `std` docs accordingly.

The PR also removes the single usage of the macro outside of `std` as it does not seem like the macro is actually needed there.
2025-09-09 14:35:04 +10:00
Stuart Cook
598577911f Rollup merge of #146300 - bjoernager:f16-f128-sum-product, r=jhpratt
Implement `Sum` and `Product` for `f16` and `f128`.

Tracking issue: rust-lang/rust#116909.

This PR implements `core::iter::{Sum, Product}` for `f16` and `f128`.

I'm curious as to why these two traits aren't already implemented. I've been unable to find any information about it at all, so if there is anything that currently blocks them, I would appreciate if someone could fill me in.
2025-09-09 14:35:04 +10:00
Jeremy Smart
8d0c07f1a1 change end to last 2025-09-08 22:07:43 -04:00
cyrgani
9899ab3fa4 simplify the declaration of the legacy integer modules (std::u32 etc.) 2025-09-08 22:28:36 +02:00
Matthias Krüger
803b5b56f3 Rollup merge of #146319 - justinyaodu:patch-1, r=jhpratt
Fix typo in default.rs

This sentence currently reads:

> Rust implements `Default` for various primitives types.

I think it should just be "primitive types".
2025-09-08 16:34:59 +02:00
cyrgani
edc94e6184 mark format_args_nl! as #[doc(hidden)] 2025-09-08 15:02:25 +02:00
Ralf Jung
aed0ed4c93 const-eval: disable pointer fragment support 2025-09-08 13:22:52 +02:00
bors
beeb8e3af5 Auto merge of #146173 - Kmeakin:km/unicode-data/no-ascii, r=jhpratt
Don't include ASCII characters in Unicode tables

Split off from https://github.com/rust-lang/rust/pull/145219
2025-09-08 07:25:07 +00:00
Justin Yao Du
7fa23530bf Fix typo in default.rs 2025-09-07 21:16:35 -07:00
Kivooeo
a2d66db9ba remove unsused div_rem method from bignum 2025-09-07 17:21:47 +00:00
Gabriel Bjørnager Jensen
02602ef651 Implement 'Sum' and 'Product' for 'f16' and 'f128'; 2025-09-07 18:01:39 +02:00
Karl Meakin
a8c669461f optimization: Don't include ASCII characters in Unicode tables
The ASCII subset of Unicode is fixed and will never change, so we don't
need to generate tables for it with every new Unicode version. This
saves a few bytes of static data and speeds up `char::is_control` and
`char::is_grapheme_extended` on ASCII inputs.

Since the table lookup functions exported from the `unicode` module will
give nonsensical errors on ASCII input (and in fact will panic in debug
mode), I had to add some private wrapper methods to `char` which check
for ASCII-ness first.
2025-09-07 15:21:24 +02:00
bors
f13ef0d75d Auto merge of #146216 - LorrensP-2158466:miri-float-nondet-foreign-items-take2, r=RalfJung
Miri: non-deterministic floating point operations in foreign_items

Take 2 of rust-lang/rust#143906. The last 2 commits are what changed compared to the original pr.

Verified the tests using (fish shell):
```fish
env MIRIFLAGS="-Zmiri-max-extra-rounding-error -Zmiri-many-seeds" ./x miri --no-fail-fast std core coretests  -- f32 f64
```

r? `@RalfJung`
2025-09-07 10:46:38 +00:00
LorrensP-2158466
e7e06aca38 Change stdlib float tests to account for miri nondet floats. 2025-09-06 21:45:17 +02:00
Trevor Gross
ebde667698 Rollup merge of #145940 - pascaldekloe:int-exp-tune, r=tgross35
single buffer for exponent fmt of integers

No need for fragmented buffers when formatting.

```
orig.txt: fmt::write_i128_exp                                                  143.39ns/iter      +/- 0.32
orig.txt: fmt::write_i64_exp                                                    68.72ns/iter      +/- 0.03
new.txt:  fmt::write_i128_exp                                                  138.29ns/iter      +/- 0.50
new.txt:  fmt::write_i64_exp                                                    58.93ns/iter      +/- 4.62
```

This patch fully eliminates unsafe pointer use (after rust-lang/rust#135265 and rust-lang/rust#136594).

    r? libs
2025-09-06 14:39:04 -04:00
Kivooeo
13ed4a3812 uncommented u64 impl 2025-09-06 15:45:09 +00:00
Nathaniel McCallum
00fcb14e4e clean up some old const trait impl syntax 2025-09-06 04:35:52 +02:00
ltdk
07d3e923ac Unstably constify ptr::drop_in_place and related methods 2025-09-05 17:28:22 -04:00
León Orell Valerian Liehr
d82ee660d6 Rollup merge of #146234 - hkBst:file-generated-header, r=tgross35
change file-is-generated doc comment to inner

Alternatively this could perhaps be better as a normal comment...
2025-09-05 22:47:22 +02:00
León Orell Valerian Liehr
690753f7d4 Rollup merge of #146225 - Jules-Bertholet:simplify-float-midpoint, r=tgross35
Simplify `{f16, f32, f64, f128}::midpoint()`

`(float_ty::MAX / 2) - (float_ty::MIN_POSITIVE * 2)` equals `(float_ty::MAX / 2) + (float_ty::MIN_POSITIVE * 2)` equals `(float_ty::MAX / 2)`. So these branches are pointless.

CC `@Urgau` who wrote the original implementation in https://github.com/rust-lang/rust/pull/92048; does this seem right?

`@rustbot` label A-floating-point
2025-09-05 22:47:22 +02:00
Pascal S. de Kloe
56e95aa6a9 single buffer for exponent fmt of integers 2025-09-05 19:45:12 +02:00
Marijn Schouten
98e10290c9 change file-is-generated doc comment to inner 2025-09-05 10:08:45 +00:00
Jules Bertholet
bc17bcdef0 Simplify {f16, f32, f54, f128}::midpoint()
`(float_ty::MAX / 2) - (float_ty::MIN_POSITIVE * 2)` equals
`(float_ty::MAX / 2) + (float_ty::MIN_POSITIVE * 2)` equals
`(float_ty::MAX / 2)`. So these branches are pointless
2025-09-05 02:01:18 -04: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
Jacob Pratt
00d5dc5c9d Rollup merge of #145690 - sayantn:integer-funnel-shift, r=tgross35
Implement Integer funnel shifts

Tracking issue: rust-lang/rust#145686
ACP: https://github.com/rust-lang/libs-team/issues/642

This implements funnel shifts on primitive integer types. Implements this for cg_llvm, with a fallback impl for everything else

Thanks `@folkertdev` for the fixes and tests

cc `@rust-lang/libs-api`
2025-09-04 01:43:21 -04:00
Stuart Cook
b27c94af61 Rollup merge of #146136 - AudaciousAxiom:docs/missing-closing-code-block-fences, r=tgross35
docs(std): add missing closing code block fences in doc comments

This PR adds a few closing code block fences which I believe are missing in some doc comments. It seems that rustdoc just autocloses code blocks at the end of doc comments and thus these were easily overlooked: I do not think these code blocks are special in any way.

I found these when working on a Clippy lint that checks the last sentence of doc comments for terminal punctuation, and these were failing cases when testing against the std. Therefore I am not entirely sure these are all such cases, but still have high hopes that they are (or at least a well-defined subset of them).
2025-09-04 10:02:02 +10:00
Stuart Cook
c7a11f42e0 Rollup merge of #146054 - joboet:array-repeat-must_use, r=ibraheemdev
add `#[must_use]` to `array::repeat`
2025-09-04 10:01:58 +10:00
Stuart Cook
732802c207 Rollup merge of #143725 - kennytm:peekable_next_if_map, r=jhpratt
core: add Peekable::next_if_map

Implementation for rust-lang/rust#143702
2025-09-04 10:01:51 +10:00
Stuart Cook
8b790d7b00 Rollup merge of #145414 - Kmeakin:km/unicode-table-refactors, r=joshtriplett,tgross35
unicode-table-generator refactors

Split off from https://github.com/rust-lang/rust/pull/145219
2025-09-03 23:08:06 +10:00
Stuart Cook
f4b946a147 Rollup merge of #145279 - clarfonthey:const-convert-initial, r=tgross35
Constify conversion traits (part 1)

This is the first part of rust-lang/rust#144289 being split into smaller pieces. It adds/moves constness of several traits under the `const_convert` feature:

* `From`
* `Into`
* `TryFrom`
* `TryInto`
* `FromStr`
* `AsRef`
* `AsMut`
* `Borrow`
* `BorrowMut`
* `Deref`
* `DerefMut`

There are a few methods that are intrinsically tied to these traits which I've included in the feature. Particularly, those which are wrappers over `AsRef`:

* `ByteStr::new` (unstable under `bstr` feature)
* `OsStr::new`
* `Path::new`

Those which directly use `Into`:

* `Result::into_ok`
* `Result::into_err`

And those which use `Deref` and `DerefMut`:

* `Pin::as_ref`
* `Pin::as_mut`
* `Pin::as_deref_mut`
* `Option::as_deref`
* `Option::as_deref_mut`
* `Result::as_deref`
* `Result::as_deref_mut`

(note: the `Option` and `Result` methods were suggested by ``@npmccallum`` initially as rust-lang/rust#146101)

The parts which are missing from this PR are:

* Anything that involves heap-allocated types
* Making any method const than the ones listed above
* Anything that could rely on the above, *or* could rely on system-specific code for `OsStr` or `Path` (note: this mostly makes these methods useless since `str` doesn't implement `AsRef<OsStr>` yet, but it's better to track the method for now and add impls later, IMHO)

r? ``@tgross35`` (who mostly already reviewed this)
2025-09-03 23:08:06 +10:00
sayantn
62b4347e80 Add funnel_sh{l,r} functions and intrinsics
- Add a fallback implementation for the intrinsics
 - Add LLVM backend support for funnel shifts

Co-Authored-By: folkertdev <folkert@folkertdev.nl>
2025-09-03 14:13:24 +05:30
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
ltdk
1c64d3e6d1 Constify conversion traits 2025-09-01 21:38:26 -04:00
Nathaniel McCallum
6be234074e constify impl Try for ControlFlow 2025-09-01 08:43:38 -04:00
Stuart Cook
0fa8265b3c Rollup merge of #145968 - connortsui20:bound-copied, r=joboet
Add `Bound::copied`

Tracking Issue: https://github.com/rust-lang/rust/issues/145966

Some questions:

- [x] Should I update the documentation for `cloned` to actual used a `Clone` type instead of an integer?
- [x] I removed the `must_use` since this is a cheap copy, does that make sense?
2025-09-01 12:42:25 +10:00
joboet
a44b180178 add #[must_use] to array::repeat 2025-08-31 13:52:06 +02:00
Matthias Krüger
e3881cb587 Rollup merge of #145931 - gonzalobg:patch-1, r=nagisa
Clarify that align_offset overaligns

The current documentation is not clear whether adding `a` to a pointer overaligns (align up) or underaligns (align down).

It should say this explicitly.

cc `@nagisa`
2025-08-31 13:40:36 +02:00
Matthias Krüger
59a645ac25 Rollup merge of #145174 - 197g:issue-145148-select-unpredictable-drop, r=joboet
Ensure consistent drop for panicking drop in hint::select_unpredictable

There are a few alternatives to the implementation. The principal problem is that the selected value must be owned (in the sense of having a drop flag of sorts) when the unselected value is dropped, such that panic unwind goes through the drop of both. This ownership must then be passed on in return when the drop went smoothly.

The basic way of achieving this is by extracting the selected value first, at the cost of relying on the optimizer a little more for detecting the copy as constructing the return value despite having a place in the body. Unfortunately, that causes LLVM to discard the !unpredictable annotation (for some reason that is beyond my comprehension of LLVM).

<details>
<summary>Extract from the build log showing an unannotated select being used</summary>

```
2025-08-09T16:51:06.8790764Z            39: define noundef i64 `@test_int2(i1` noundef zeroext %p, i64 noundef %a, i64 noundef %b) unnamed_addr #0 personality ptr `@rust_eh_personality` {
2025-08-09T16:51:06.8791368Z check:47'0                                  X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
2025-08-09T16:51:06.8791700Z            40: start:
2025-08-09T16:51:06.8791858Z check:47'0     ~~~~~~~
2025-08-09T16:51:06.8792043Z            41:  %ret.i = select i1 %p, i64 %a, i64 %b
2025-08-09T16:51:06.8792293Z check:47'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-08-09T16:51:06.8792686Z check:47'1               ?                             possible intended match
2025-08-09T16:51:06.8792946Z            42:  ret i64 %ret.i
2025-08-09T16:51:06.8793127Z check:47'0     ~~~~~~~~~~~~~~~~
```

</details>

So instead, this PR includes a guard to drop the selected `MaybeUnit<T>` which is active only for the section where the unselected value is dropped. That leaves the code for selecting the result intact leading to the expected ir. That complicates the 'unselection' process a little bit since we require _both_ values as a result of that intrinsic call. Since the arguments alias, this portion as well as the drop guard uses raw pointers.

Closes: rust-lang/rust#145148
Prior: rust-lang/rust#139977
2025-08-31 13:40:35 +02:00
bors
0f50696801 Auto merge of #145479 - Kmeakin:km/hardcode-char-is-control, r=joboet
Hard-code `char::is_control`

Split off from https://github.com/rust-lang/rust/pull/145219

According to
https://www.unicode.org/policies/stability_policy.html#Property_Value, the set of codepoints in `Cc` will never change. So we can hard-code the patterns to match against instead of using a table.

This doesn't change the generated assembly, since the lookup table is small enough that[ LLVM is able to inline the whole search](https://godbolt.org/z/bG8dM37YG). But this does reduce the chance of regressions if LLVM's heuristics change in the future, and means less generated Rust code checked in to `unicode-data.rs`.
2025-08-30 14:18:21 +00:00
Aurelia Molzer
ee9803a244 Switch select_unpredictable guard to raw pointer 2025-08-30 13:01:36 +02:00
Aurelia Molzer
354787b5ba Simplify select_unpredictable guard selection
Instead of a tuple, select the dropped value and its guard with two
separate calls to the intrinsic which makes both calls have a
pointer-valued argument that should be simpler in codegen. Use the same
condition on all (not an inverted condition) to clarify the intent of
parallel selection. This should also be a simpler value-dependency chain
if the guard is deduced unused (i.e. drop_in_place a noop for the type).
2025-08-30 13:01:36 +02:00
Stuart Cook
f655e6a863 Rollup merge of #145969 - actuallylost:duration-from-nanos-128, r=tgross35
Add Duration::from_nanos_u128

Feature Gate: `#![feature(duration_from_nanos_u128)]`
ACP: https://github.com/rust-lang/libs-team/issues/567
Tracking issue: https://github.com/rust-lang/rust/issues/139201
Recreated from https://github.com/rust-lang/rust/pull/139243
2025-08-30 20:29:08 +10:00
Stuart Cook
dfbba07012 Rollup merge of #145776 - ChaiTRex:ilog_specialization, r=joboet
Optimize `.ilog({2,10})` to `.ilog{2,10}()`

Optimize `.ilog({2,10})` to `.ilog{2,10}()`

Inform compiler of optimizations when the base is known at compile time and there's a cheaper method available:

* `{integer}.checked_ilog(2)` -> `{integer}.checked_ilog2()`
* `{integer}.checked_ilog(10)` -> `{integer}.checked_ilog10()`
* `{integer}.ilog(2)` -> `{integer}.ilog2()`
* `{integer}.ilog(10)` -> `{integer}.ilog10()`
2025-08-30 20:29:07 +10:00
Stuart Cook
b5c19e839f Rollup merge of #145465 - Kivooeo:stabilize-array_repeat, r=joboet
Stabilize `array_repeat` feature

This closes [tracking issue](https://github.com/rust-lang/rust/issues/126695) and stabilises `array::repeat`
2025-08-30 20:29:06 +10:00
Connor Tsui
114c0c2fef Add #[must_use] and update cloned` documentation
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2025-08-30 11:26:26 +01:00
Connor Tsui
9c1255f0a4 add feature gate in doc test 2025-08-30 10:48:27 +01:00