Commit Graph

9765 Commits

Author SHA1 Message Date
Urgau 0e8d1e1f8e Add #[rustc_should_not_be_called_on_const_items] to std methods 2025-11-22 14:48:35 +01:00
Stuart Cook e7b9935fc5 Rollup merge of #149135 - nxsaken:const_residual_into_try_type, r=scottmcm
Constify `residual_into_try_type`

Feature: `const_try_residual` (related to `try_trait_v2_residual`)
Tracking issue: rust-lang/rust#91285

Constify `residual_into_try_type` introduced in rust-lang/rust#148725.

r? ``@scottmcm``
2025-11-21 14:44:43 +11:00
Stuart Cook f8bc31a804 Rollup merge of #149127 - bend-n:iter_array_chunks_into_remainder_is_non_optional, r=dtolnay
unwrap ret ty of `iter::ArrayChunks::into_remainder`

changes [`iter::ArrayChunks::into_remainder`](https://github.com/rust-lang/rust/issues/100450) to return `array::IntoIter` instead of `Option<array::IntoIter>` as suggested by [`@WaffleLapkin](https://github.com/rust-lang/rust/issues/100450#issuecomment-3555519025)`
2025-11-21 14:44:42 +11:00
bors 53732d5e07 Auto merge of #149109 - scottmcm:align-always-alignment, r=tgross35
See if this is the time we can remove `layout::size_align`

This was a bad idea before, but now that `size_of` and `align_of` work completely differently than when removing it was first tried in 2020, maybe it makes sense now.

(Or maybe I'll just add another attempt to the list in the comments...)

r? ghost
2025-11-20 19:01:43 +00:00
bors 7281a3bc4b Auto merge of #149132 - matthiaskrgr:rollup-8khp9s2, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#146925 (Add doc for va_list APIs)
 - rust-lang/rust#147035 (alloc: fix `Debug` implementation of `ExtractIf`)
 - rust-lang/rust#147173 (Add support for hexagon-unknown-qurt target)
 - rust-lang/rust#148261 (rustc_public: Make Id types !Send / !Sync)
 - rust-lang/rust#149041 (ignore unsized types in mips64 and sparc64 callconvs)
 - rust-lang/rust#149056 (fix the fragment_in_dst_padding_gets_overwritten test on s390x)
 - rust-lang/rust#149071 (Add test scaffolding for the `remote-test-client`)
 - rust-lang/rust#149095 (rustc-dev-guide subtree update)
 - rust-lang/rust#149108 ([AIX][ppc64le-linux-gnu] Add Amy Kwan to target maintainers)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-20 13:25:16 +00:00
nxsaken 5590d7db51 Constify residual_into_try_type 2025-11-20 15:08:11 +04:00
Matthias Krüger 2eeec770fe Rollup merge of #146925 - DiuDiu777:va-doc-fix, r=tgross35
Add doc for va_list APIs

I observed that [PR146521](https://github.com/rust-lang/rust/pull/146521) submitted two weeks ago resolved some documentation issues related to `VaListImpl`, similar to the previous [PR136969](https://github.com/rust-lang/rust/pull/136969).

This PR specifically adds requirements about argument availability for `VaListImpl::arg`, and also adds safety descriptions to the three associated intrinsic APIs.
2025-11-20 11:15:49 +01:00
bors 2c0f4860cc Auto merge of #149118 - folkertdev:stdarch-sync-2025-11-19, r=tgross35
stdarch subtree update

Subtree update of `stdarch` to https://github.com/rust-lang/stdarch/commit/50134e10cbd2f81a068259d7796aff2471aae7c1.

Created using https://github.com/rust-lang/josh-sync.

The only interesting commit is the final one, which enables the `avx10_target_feature` feature in the standard library, because it is now used in `stdarch`.

r? `@sayantn` (or whoever, this is just a straightforward sync)
2025-11-20 10:08:24 +00:00
bendn 68abe69f13 iter::ArrayChunks::into_remainder ought not return option 2025-11-20 15:27:57 +07:00
Folkert de Vries ae682a3862 enable avx10_target_feature in core (used by stdarch) 2025-11-20 00:27:56 +01:00
Scott McMurray 30f4a2ae16 See if this is the time we can remove layout::size_align
This was a bad idea before, but now that `size_of` and `align_of` work completely differently than when removing it was first tried in 2020, maybe it makes sense now.

(Or maybe I'll just add another attempt to the list in the comments...)
2025-11-19 12:55:21 -08:00
Matthias Krüger 48fa9138c3 Rollup merge of #148798 - tamird:esc-single-quote, r=Amanieu
Match <OsString as Debug>::fmt to that of str

Fixes rust-lang/rust#114583.
2025-11-19 09:48:10 +01:00
Matthias Krüger 8b7479003b Rollup merge of #148797 - sorairolake:feature/non-zero-uint-bit-width, r=scottmcm
feat: Add `bit_width` for unsigned `NonZero<T>`

- Tracking issue: rust-lang/rust#142326

This pull request adds a method to the unsigned `NonZero<T>` that return the minimum number of bits required to represent a value.

This can be achieved by using the `get` method and the methods added in rust-lang/rust#142328, but I think adding the `NonZero::bit_width` method is useful because it accomplishes the same thing a little more succinctly.
2025-11-19 09:48:09 +01:00
Matthias Krüger 3732c3c068 Rollup merge of #148201 - ZuseZ4:autodiff-activity-docs, r=oli-obk
Start documenting autodiff activities

Some initial documentation of the autodiff macros and usage examples
2025-11-19 09:48:08 +01:00
Matthias Krüger 714f1cea15 Rollup merge of #147521 - sayantn:simd-const-intrinsics, r=madsmtm
Make SIMD intrinsics available in `const`-contexts

successor to rust-lang/rust#146568, this PR actually makes the SIMD intrinsics `const`, and modifies the tests to test the const-eval implementations

r? `@tgross35` ig (although feel free to reassign, this is not anything targeted really)
2025-11-19 09:48:07 +01:00
Matthias Krüger 847c422cea Rollup merge of #147171 - Qelxiros:hashmap_diag, r=fee1-dead
recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher

closes rust-lang/rust#147147

~The suggestion span is wrong, but I'm not sure how to find the right one.~ fixed

I'm relatively new to the diagnostics ecosystem, so I'm not sure if `span_help` is the right choice. `span_suggestion_*` might be better, but the output from `x test` looks weird in that case.
2025-11-19 09:48:05 +01:00
Shun Sakai a25950dec6 feat: Change return type of NonZero::bit_width
Return `NonZero<u32>` instead of `u32`.
2025-11-19 03:17:38 +09:00
Matthias Krüger e6d08c6521 Rollup merge of #147887 - matthieu-m:task/lib-core-sync-atomic-fence-doc-improvement, r=Mark-Simulacrum
Improve the documentation of atomic::fence

Attempt to "fix" two flaws of the current documentation:

1. The over-emphasis of fence - fence synchronization, relegating atomic - fence and fence - atomic synchronization to second fiddle.
2. The lack of explanation as to how to properly perform atomic - fence and fence - atomic synchronization.

It does so by first making it clear that there are 3 different ways to use an atomic fence, then presenting a full example for each usecase, noting the particular position of the fence with regard to the atomic operation, and rounding up with generic notes.
2025-11-18 16:52:10 +01:00
Camille Gillot aeb9332b28 Complete doc. 2025-11-18 00:10:04 +00:00
Camille Gillot 12e91cf814 Honor allow_internal_unstable for const intrinsics. 2025-11-18 00:10:03 +00:00
Camille Gillot 72444372ae Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
Tamir Duberstein 1cfd0b7c55 Match <OsString as Debug>::fmt to that of str
819247f1 changed <str as Debug>::fmt such that it does not escape single
quotes, but neglected to apply the same choice to OsString. This commit
does that.
2025-11-17 16:05:00 -05:00
Matthieu M 5431c6fd8e Improve the documentation of atomic::fence
Attempt to "fix" two flaws of the current documentation:

1. The over-emphasis of fence - fence synchronization, relegating
   atomic - fence and fence - atomic synchronization to second fiddle.
2. The lack of explanation as to how to properly perform atomic - fence
   and fence - atomic synchronization.

It does so by first making it clear that there are 3 different ways to
use an atomic fence, then presenting a full example for each usecase,
noting the particular position of the fence with regard to the atomic
operation, and rounding up with generic notes.
2025-11-17 18:12:43 +01:00
Matthias Krüger 4e5c61e932 Rollup merge of #148504 - NeatNit:intlong, r=ibraheemdev
Fix link in c_longlong documentation

Ran across this mistake when reading [the documentation](https://doc.rust-lang.org/std/ffi/type.c_longlong.html). I went through the other `.md` files in this directory and didn't spot any other errors.

**I did not check the output of this change** - I couldn't figure out how to get `cargo doc` to work and I figured it's not worth the distraction. It can't really go wrong, can it?
2025-11-17 18:07:32 +01:00
Matthias Krüger 5dd82e8ed9 Rollup merge of #145610 - GrigorenkoPV:char_max_len, r=Amanieu
Stabilize `char_max_len`

Tracking issue: rust-lang/rust#121714

r? t-libs-api

`@rustbot` label +needs-fcp -T-libs +T-libs-api

Closes rust-lang/rust#121714
2025-11-17 18:07:31 +01:00
Jeremy Smart 754a82d87c recommend using a HashMap if a HashSet's second generic parameter doesn't implement BuildHasher 2025-11-17 11:56:21 -05:00
bors cc328c1238 Auto merge of #149013 - Zalathar:rollup-io1ddhc, r=Zalathar
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#148505 (add larger test for `proc_macro` `FromStr` implementations)
 - rust-lang/rust#148752 (Constify `ManuallyDrop::take`)
 - rust-lang/rust#148757 (Constify `mem::take`)
 - rust-lang/rust#148855 (Error if an autodiff user does not set lto=fat)
 - rust-lang/rust#148912 (add note to `lines` docs about empty str behavior)
 - rust-lang/rust#148958 (Run codegen tests on a 32-bit target in PR CI)
 - rust-lang/rust#148994 (Abi compatibility test cleanup)
 - rust-lang/rust#148999 (Tweak Motor OS linker preset, fix `remote-test-server` for Motor OS)
 - rust-lang/rust#149004 (compiletest: Avoid race condition in file deletion)
 - rust-lang/rust#149008 (triagebot: remove jsha from notifications for rustdoc HTML)
 - rust-lang/rust#149010 (compiletest: Remove the "wasm32-bare" alias for `wasm32-unknown-unknown`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-17 07:49:48 +00:00
Stuart Cook 47585c9f48 Rollup merge of #148912 - msmoiz:main, r=scottmcm
add note to `lines` docs about empty str behavior

This pull request adds a short note to the documentation for `str::lines` that describes the behavior of the resulting iterator when called on an empty string. I tripped over this a few days ago because I thought (incorrectly) that the iterator would return a single line with an empty string. I don't doubt that the actual behavior (return no lines) is the correct behavior, but in the absence of explicit documentation describing it, I came to the wrong conclusion about it and maybe others will too. If this is so obvious as to be not worth including, I'm happy to withdraw the pull request! Thanks for taking a look.
2025-11-17 16:41:03 +11:00
Stuart Cook 6fe5c1d544 Rollup merge of #148757 - nxsaken:const_mem_take, r=scottmcm
Constify `mem::take`

Feature: `const_default` (rust-lang/rust#143894)
2025-11-17 16:41:02 +11:00
Stuart Cook dd9b8e65a4 Rollup merge of #148752 - nxsaken:const_manually_drop_take, r=scottmcm
Constify `ManuallyDrop::take`

Feature: `const_manually_drop_take`
Tracking issue: rust-lang/rust#148773

This PR constifies `ManuallyDrop::take`.
2025-11-17 16:41:01 +11: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
Manuel Drehwald f5892da3f2 add autodiff examples 2025-11-16 23:35:37 -05:00
Matthias Krüger 79d765ed38 Rollup merge of #148703 - pitaj:rangefrom-overflow_checks, r=Mark-Simulacrum
Use `overflow_checks` intrinsic so `IterRangeFrom` yields MAX before panicking in debug

Based on rust-lang/rust#128666. For your convenience, here is the [diff from that PR](https://github.com/pitaj/rust/compare/intrinsic-overflow_checks...pitaj:rust:rangefrom-overflow_checks).

When `overflow_checks` are enabled, the following code will output as shown
```rust
for n in std::range::RangeFrom::from(253_u8..) {
    println!("{n}");
}
// 253
// 254
// 255
// panic
```

Which is a change from the current behavior, where it will panic after printing 254.

This behavior was [requested by the libs team](https://github.com/rust-lang/rust/issues/125687#issuecomment-2151118208)

r? `@Mark-Simulacrum`
2025-11-16 20:40:22 +01:00
bors e1a2ec6051 Auto merge of #148259 - RalfJung:const-ptr-fragment, r=oli-obk
const-eval: fix and re-enable pointer fragment support

The pointer fragment support from https://github.com/rust-lang/rust/pull/144081 got disabled due to https://github.com/rust-lang/rust/issues/146291. This brings it back. To fix the issue, the per-byte provenance fragment tracking tracks *both* the provenance and raw address of the full pointer, so we can ensure that only fragments that are truly part of the same pointer are being merged.

r? `@oli-obk`
Cc `@theemathas`
Fixes https://github.com/rust-lang/const-eval/issues/72 again.
Also fixes https://github.com/rust-lang/rust/issues/147959.

`@traviscross` I assume this won't need another t-lang FCP since it already got FCP'd in rust-lang/rust#144081?
2025-11-16 07:09:45 +00:00
Peter Jaszkowiak 0e5c96c3ec IterRangeFrom: overflow panic after yielding MAX
check overflow after yielding MAX value
new `0_u8..` will yield `255` and only panic on the subsequent `next()`
2025-11-15 21:29:59 -07:00
Peter Jaszkowiak 6d2eb33391 fix a couple unstable attributes 2025-11-15 21:29:59 -07:00
Stuart Cook 8ea74b1a8f Rollup merge of #148836 - ericseppanen:primitive_reference_docs, r=Mark-Simulacrum
tweak primitive reference docs

This is a docs-only change for primitive reference.

I noticed a typo ("safe to use at type `T`") and fixed it to read "safe to use *as* type `T`".

While reading over the whole page, I also noticed another sentence that was hard to read. I tried to improve it: feel free to comment on the wisdom of this change...
2025-11-16 14:39:59 +11:00
Stuart Cook ec2f7397ce Rollup merge of #148827 - GoldsteinE:stabilize-vec-into-raw-parts, r=Mark-Simulacrum
Stabilize vec_into_raw_parts

This stabilizes `Vec::into_raw_parts()` and `String::into_raw_parts()` per FCP in https://github.com/rust-lang/rust/issues/65816#issuecomment-3517630971. While this _does not_ stabilize `Vec::into_parts()`, I fixed up the examples that said they were waiting for `vec_into_raw_parts`. As `Vec::from_parts()` and `Vec::into_parts()` are covered by the same feature `box_vec_non_null`, any doctest that uses `Vec::from_parts()` can also use `Vec::into_parts()` (and same for allocator-aware versions).

Closes rust-lang/rust#65816

``@rustbot`` modify labels: +T-libs-api
2025-11-16 14:39:58 +11: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
Ralf Jung 907fd85e16 const-eval: fix and re-enable pointer fragment support 2025-11-15 10:09:42 +01:00
bors b6d7ff3aa7 Auto merge of #148944 - theemathas:rm_inherit_overflow, r=joboet
Remove `rustc_inherit_overflow_checks` from `position()` in slice iterators

This method implementation can never cause an overflow, since `i` can never go over the slice's length.
2025-11-14 18:47:43 +00:00
Pavel Grigorenko f9dcc6b21c Stabilize char_max_len 2025-11-14 18:23:19 +03:00
Theemathas Chirananthavat 8d075ae0aa Remove rustc_inherit_overflow_checks from position() in slice iterators
This method implementation can never cause an overflow,
since `i` can never go over the slice's length.
2025-11-14 20:12:11 +07:00
bors c91009892b Auto merge of #148940 - dtolnay:implarguments, r=joboet
Combine `impl<'a> Arguments<'a>` blocks

This makes a difference in the documentation rendered by rustdoc.

**Before:**

<p align="center"><img width="700" src="https://github.com/user-attachments/assets/cd5cc519-a8fa-4409-a347-f5a19638efc1" /></p>

**After:**

<p align="center"><img width="700" src="https://github.com/user-attachments/assets/4c6a9564-7f46-4879-a085-51715453bbae" /></p>
2025-11-14 12:19:17 +00:00
David Tolnay 85332e39d2 Combine impl<'a> Arguments<'a> blocks 2025-11-14 02:12:43 -08:00
Stuart Cook f61bfb0037 Rollup merge of #148725 - scottmcm:experiment-new-try-block-v3, r=petrochenkov
Implement the alternative `try` block desugaring

As discussed in https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727, update the `try` in nightly to match the RFC as a way to experiment.

This addresses the following unresolved issue from https://github.com/rust-lang/rust/issues/31436

>  Address issues with type inference (`try { expr? }?` currently requires an explicit type annotation somewhere).
2025-11-14 19:57:06 +11:00
Scott McMurray e5803fceed Move into_try_type to a free function 2025-11-13 19:53:02 -08:00
Stuart Cook 355e4cf8d6 Rollup merge of #148906 - m-ou-se:fmt-args-from-str, r=dtolnay
Expose fmt::Arguments::from_str as unstable.

Now that https://github.com/rust-lang/rust/pull/148789 is merged, we can have a fmt::Arguments::from_str. I don't know if we want to commit to always having an implementation that allows for this, but we can expose it as unstable for now so we can play with it.

Tracking issue: https://github.com/rust-lang/rust/issues/148905
2025-11-14 13:14:08 +11:00
Stuart Cook 7481e91e65 Rollup merge of #148826 - btj:cstr-docs, r=joboet
CStr docs: Fix CStr vs &CStr confusion

The CStr documentation used to say things about CStr that are only true for &CStr.

Also, it's the bytes that are being borrowed, not the reference. One could say that it's the reference that is doing the borrowing, rather than being borrowed.
2025-11-14 13:14:01 +11:00
msmoiz e628b059bb update language from "no lines" to "empty iterator" 2025-11-13 16:44:07 -08:00