28293 Commits

Author SHA1 Message Date
Jonathan Brouwer dde4886801 Rollup merge of #146181 - Flakebi:dynamic-shared-memory, r=ZuseZ4,Sa4dus,workingjubilee,RalfJung,nikic,kjetilkjeka,kulst
Add intrinsic for launch-sized workgroup memory on GPUs

Workgroup memory is a memory region that is shared between all
threads in a workgroup on GPUs. Workgroup memory can be allocated
statically or after compilation, when launching a gpu-kernel.
The intrinsic added here returns the pointer to the memory that is
allocated at launch-time.

# Interface

With this change, workgroup memory can be accessed in Rust by
calling the new `gpu_launch_sized_workgroup_mem<T>() -> *mut T`
intrinsic.

It returns the pointer to workgroup memory guaranteeing that it is
aligned to at least the alignment of `T`.
The pointer is dereferencable for the size specified when launching the
current gpu-kernel (which may be the size of `T` but can also be larger
or smaller or zero).

All calls to this intrinsic return a pointer to the same address.

See the intrinsic documentation for more details.

## Alternative Interfaces

It was also considered to expose dynamic workgroup memory as extern
static variables in Rust, like they are represented in LLVM IR.
However, due to the pointer not being guaranteed to be dereferencable
(that depends on the allocated size at runtime), such a global must be
zero-sized, which makes global variables a bad fit.

# Implementation Details

Workgroup memory in amdgpu and nvptx lives in address space 3.
Workgroup memory from a launch is implemented by creating an
external global variable in address space 3. The global is declared with
size 0, as the actual size is only known at runtime. It is defined
behavior in LLVM to access an external global outside the defined size.

There is no similar way to get the allocated size of launch-sized
workgroup memory on amdgpu an nvptx, so users have to pass this
out-of-band or rely on target specific ways for now.

Tracking issue: rust-lang/rust#135516
2026-04-25 23:07:48 +02:00
Jacob Pratt b3ccc964d5 Rollup merge of #154372 - Apersoma:float_masks, r=tgross35
Exposing Float Masks

Tracking issue: rust-lang/rust#154064
ACP: rust-lang/libs-team#753
2026-04-25 01:21:52 -04:00
Apersoma d5b941d163 added float masks feature 2026-04-24 23:06:04 +00:00
Jonathan Brouwer 6f536cf8f4 Rollup merge of #155741 - xtqqczze:question-mark-bufwriter-flush, r=WaffleLapkin
std: Refactor BufWriter::flush to use the `?` operator

Functionally, this is equivalent and may     be slightly more amenable to inlining.
2026-04-25 00:08:11 +02:00
Jonathan Brouwer 6d6b99eab2 Rollup merge of #155754 - folkertdev:hide-core-ffi-va-list, r=tgross35
make the `core::ffi::va_list` module private

tracking issue: https://github.com/rust-lang/rust/issues/44930

the types are exported from `core::ffi` itself.

T-libs-api decided that we should only export the types from `core::ffi`, and should not make `core::ffi::va_list` public, see https://github.com/rust-lang/rust/issues/44930#issuecomment-4289951633.

r? tgross35
2026-04-25 00:08:09 +02:00
Folkert de Vries 3851c60cf8 make the core::ffi::va_list module private
the types are exported from `core::ffi` itself
2026-04-24 22:18:22 +02:00
Jonathan Brouwer 4eaa44b4a8 Rollup merge of #155735 - Muhtasim-Rasheed:issue-155695-fix-typo, r=wesleywiser
Fix typo by removing extra 'to'

Fixes rust-lang/rust#155695

Fix a typo in the `std::convert` module documentation by removing an extra "to" in the module-level docs.
2026-04-24 18:19:21 +02:00
Jonathan Brouwer e873839964 Rollup merge of #155621 - mejrs:document_diagnostic_on_move, r=chenyukang
Document #[diagnostic::on_move] in the unstable book.

Also adds the attribute on `std::fs::File` to stay consistent with the prose in the unstable book entry.

cc @estebank @rperier

Rendered:
<img width="791" height="903" alt="image" src="https://github.com/user-attachments/assets/a27a5211-7717-4f7f-a514-8316dccc78d5" />
<img width="779" height="390" alt="image" src="https://github.com/user-attachments/assets/a983108d-575e-4551-ab14-28611344e9b0" />
2026-04-24 18:19:14 +02:00
xtqqczze 15e60ebe6e std: Refactor flush method in BufWriter to use the ? operator 2026-04-24 15:19:36 +01:00
Muhtasim-Rasheed 52b93e04f8 Fix typo by removing extra 'to' 2026-04-24 18:18:08 +06:00
bors ec6f9a5b44 Auto merge of #155709 - tgross35:compiler-builtins-sync-2026-04-22, r=tgross35
compiler-builtins subtree update

Subtree update of `compiler-builtins` to https://github.com/rust-lang/compiler-builtins/commit/4d3ab8695dcf965be926882c92878b99017bf99b.

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

Closes: https://github.com/rust-lang/rust/pull/155653
2026-04-24 10:39:25 +00:00
Flakebi 13ec3de673 Add intrinsic for launch-sized workgroup memory on GPUs
Workgroup memory is a memory region that is shared between all
threads in a workgroup on GPUs. Workgroup memory can be allocated
statically or after compilation, when launching a gpu-kernel.
The intrinsic added here returns the pointer to the memory that is
allocated at launch-time.

# Interface

With this change, workgroup memory can be accessed in Rust by
calling the new `gpu_launch_sized_workgroup_mem<T>() -> *mut T`
intrinsic.

It returns the pointer to workgroup memory guaranteeing that it is
aligned to at least the alignment of `T`.
The pointer is dereferencable for the size specified when launching the
current gpu-kernel (which may be the size of `T` but can also be larger
or smaller or zero).

All calls to this intrinsic return a pointer to the same address.

See the intrinsic documentation for more details.

## Alternative Interfaces

It was also considered to expose dynamic workgroup memory as extern
static variables in Rust, like they are represented in LLVM IR.
However, due to the pointer not being guaranteed to be dereferencable
(that depends on the allocated size at runtime), such a global must be
zero-sized, which makes global variables a bad fit.

# Implementation Details

Workgroup memory in amdgpu and nvptx lives in address space 3.
Workgroup memory from a launch is implemented by creating an
external global variable in address space 3. The global is declared with
size 0, as the actual size is only known at runtime. It is defined
behavior in LLVM to access an external global outside the defined size.

There is no similar way to get the allocated size of launch-sized
workgroup memory on amdgpu an nvptx, so users have to pass this
out-of-band or rely on target specific ways for now.
2026-04-24 10:03:45 +02:00
Jacob Pratt 46362de036 Rollup merge of #155669 - cammeresi:20260422-sender-diag, r=mejrs
Add `Sender` diagnostic item for `std::sync::mpsc::Sender`

Similar to the existing `Receiver` item, it will be used in Clippy to detect uses of `is_disconnected` that are racy.

Tracking issue: rust-lang/rust#153668
Suggested: https://github.com/rust-lang/libs-team/issues/748#issuecomment-4032790302
2026-04-24 02:42:51 -04:00
Jacob Pratt e002c6c726 Rollup merge of #155684 - bushrat011899:blanket_io_seek_for_ref, r=jhpratt
Generalize IO Traits for `Arc<T>` where `&T: IoTrait`

ACP: https://github.com/rust-lang/libs-team/issues/755
Tracking issue: https://github.com/rust-lang/rust/issues/154046
Related: rust-lang/rust#94744

## Description

After experimenting with rust-lang/rust#155625, I noticed `Seek` and `SeekFrom` can almost be moved to `core::io`. Unfortunately, the implementation of `Seek` for `Arc<File>` is a blocker for such a move, since `Arc` is not a fundamental type. This PR attempts to resolve this potential blocker by replacing the implementation with a more general alternative. An internal trait `IoHandle` has been added which types can implement to opt-in to `Read`/`Write`/`Seek` implementations for `Arc<Self>` as long as `&Self` implements said trait. Note that `BufRead` is excluded as the signature for `fill_buf` would require returning from a temporary.

Since this "blanket" implementation only applies to a single type which already implements the same traits, I believe this should have no user-facing impact.

If this PR was merged, rust-lang/rust#134190 could be replaced with a 2 line PR:
```rust
impl IoHandle for TcpStream {}
impl IoHandle for UnixStream {}
```
Likewise for any other types, a table of which can be found [here](https://github.com/rust-lang/libs-team/issues/504#issuecomment-2539569736). This is out of scope for this PR to avoid the need for an ACP.

---

## Notes

* See [this comment](https://github.com/rust-lang/rust/issues/154046#issuecomment-4303975612) for further details.
* No AI tooling of any kind was used during the creation of this PR.
2026-04-24 02:42:49 -04:00
Zac Harrold 7ba9478184 Implement Read/Write/Seek for Arc<T>
Added a marker trait `IoHandle` which can be used by the standard library to opt-in types to a blanket implementation of the various IO traits on `Arc<T>` where `&T: IoTrait` for some `IoTrait`.

The marker is required to avoid types like `Arc<[u8]>`  being included, since they don't have interior mutability and would not give expected results.
2026-04-24 14:26:09 +10:00
Trevor Gross 0a5785734c c-b: Ensure check-cfg is set for all targets
Emscripten and OpenBSD exit out of the build script early. Since
02014b06c1a3 ("c-b: Turn `mem-unaligned` from a feature to a cfg"), this
meant that the exit happened before all `rustc-check-cfg`s had been
emitted.

Rework the logic so these only skip the C build rather than the rest of
configuration.
2026-04-24 00:27:24 +00:00
Sidney Cammeresi 70fe8a6dc4 Add Sender diagnostic item for std::sync::mpsc::Sender
Similar to the existing `Receiver` item, it will be used in Clippy to
detect uses of `is_disconnected` that are racy.
2026-04-23 17:19:39 -07:00
Jonathan Brouwer f586047144 Rollup merge of #155652 - ChrisDenton:empty-docs, r=jhpratt
Expand `Path::is_empty` docs

Give some reasons why you might want to check if a path is empty. The `Path::join` behaviour can be surprising if you're not aware it might happen.
2026-04-23 09:38:26 +02:00
Jonathan Brouwer d289cc7f53 Rollup merge of #155614 - folkertdev:rename-next-arg, r=tgross35
c-variadic: rename `VaList::arg` to `VaList::next_arg`

tracking issue: https://github.com/rust-lang/rust/issues/44930

per [the T-libs-api meeting](https://hackmd.io/d9D6vUnuTnCWygkc3hffEw#nominated-rusttf44930-Tracking-issue-for-RFC-2137-Support-defining-C-compatible-variadic-functions-in-Rust-c_variadic), rename `VaList::arg` to `VaList::next_arg`.
2026-04-23 09:38:23 +02:00
Jonathan Brouwer 04bcb393ab Rollup merge of #155265 - Apersoma:isqrt-smarter, r=jhpratt,tgross35
Improved assumptions relating to isqrt

Improved various assumptions relating to values yielded by `isqrt`.
Does not solve but does improve rust-lang/rust#132763.

Re-openeing of rust-lang/rust#154115

Added assumptions are:
* if `x` is nonzero then `x.isqrt()`  is nonzero
* `x.isqrt() <= x`
* `x.isqrt() * x.isqrt() <= x`
2026-04-23 09:38:21 +02:00
Folkert de Vries ca43552c13 add the mem feature back to compiler-builtins/Cargo.toml
this was removed by accident before, and only discovered now that we're syncing with the main repo
2026-04-23 00:59:32 +02:00
Apersoma e722ba58ed improved assumptions relating isqrt (squashed) 2026-04-22 21:58:59 +00:00
Chris Denton 110e67c9c2 Expand Path::is_empty docs 2026-04-22 17:41:52 +00:00
Jonathan Brouwer d7bb378724 Rollup merge of #155133 - cuviper:duration_fp_docs, r=the8472
Document precision considerations of `Duration`-float methods

A `Duration` is essentially a 94-bit value (64-bit sec and ~30-bit ns),
so there's some inherent loss when converting to floating-point for
`mul_f64` and `div_f64`. We could go to greater lengths to compute these
with more accuracy, like rust-lang/rust#150933 or rust-lang/rust#154107,
but it's not clear that it's worth the effort. The least we can do is
document that some rounding is to be expected, which this commit does
with simple examples that only multiply or divide by `1.0`.

This also changes the `f32` methods to just forward to `f64`, so we keep
more of that duration precision, as the range is otherwise much more
limited there.
2026-04-22 19:18:27 +02:00
Folkert de Vries 84cd23b3c8 c-variadic: rename VaList::arg to VaList::next_arg 2026-04-22 16:02:11 +02:00
yukang 8d75f0cbfc add on_unmatch_args 2026-04-22 19:28:44 +08:00
Jacob Pratt 48f36eda77 Rollup merge of #155613 - folkertdev:c-variadic-doc-tweaks, r=tgross35
c-variadic: tweak `std` docs

tracking issue: https://github.com/rust-lang/rust/issues/44930

In preparation of a rename of `arg` to `next_arg`

cc @workingjubilee
r? tgross35
2026-04-22 01:53:42 -04:00
mejrs 70cf3f4fda Put #[diagnostic::on_move] on File 2026-04-21 23:42:33 +02:00
Folkert de Vries 6ca836bc5b c-variadic: tweak std docs 2026-04-21 22:44:26 +02:00
Alex Crichton 1dea6b8c3b std: Update support for wasm32-wasip3
This commit performs some minor update within the standard library for
the `wasm32-wasip3` target. This target is a tier 3 target currently due
to the WASIp3 specification not being officially released. This commit
adds a dependency from the standard library on the `wasip3` crate in the
same manner as the `wasip1` and `wasip2` crates that it already depends
on. The use-sites, for randomness and environment variables, are then
updated to handle the wasip2/wasip3 multiplexing.
2026-04-21 09:26:25 -07:00
Jacob Pratt b4bab32075 Rollup merge of #155565 - Lars-Schumann:const-vec-cmp, r=jhpratt
constify `Vec` comparisons

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

Due to `Cow` not implementing `const Deref` (https://github.com/rust-lang/rust/issues/147964), the comparisons including a `Cow` were not constified.
2026-04-21 02:20:28 -04:00
Jacob Pratt 53b9b9a108 Rollup merge of #155564 - tshakalekholoane:tshaka/const_default/cstr, r=jhpratt
Implement const Default for &CStr

Implements `const Default` for `&CStr`.

Tracking issue: rust-lang/rust#143894.
2026-04-21 02:20:27 -04:00
Jacob Pratt 64b897180d Rollup merge of #155559 - safer-rust:fix-doc2, r=jhpratt
add safety doc (section header) to two unsafe methods in `NonZero`

This PR adds a Safety section to two unsafe methods in `NonZero`:
- [unchecked_add](https://doc.rust-lang.org/nightly/core/num/struct.NonZero.html#method.unchecked_add)
- [unchecked_mul](https://doc.rust-lang.org/nightly/core/num/struct.NonZero.html#method.unchecked_mul)

The safety documentation is now consistent with that of [`u8::unchecked_add`](https://doc.rust-lang.org/nightly/core/primitive.u8.html#method.unchecked_add) and [`u8::unchecked_mul`](https://doc.rust-lang.org/nightly/core/primitive.u8.html#method.unchecked_mul).
2026-04-21 02:20:26 -04:00
Jacob Pratt 156cc9fb23 Rollup merge of #155558 - nivekithan:issue-154000-fix, r=jhpratt
Clarify that isqrt returns the principal (non-negative) square root

Clarify which root is returned from `isqrt` and `checked_isqrt`

Fixes: https://github.com/rust-lang/rust/issues/154000
Previous PRs: https://github.com/rust-lang/rust/pull/154462
2026-04-21 02:20:26 -04:00
Jacob Pratt 387df6efb1 Rollup merge of #155532 - StepfenShawn:patch-1, r=jhpratt
Fix redundant boolean comparison in `Mutex::try_lock`

Simplify boolean return in `Mutex::try_lock`.
Replace `expr == false` with `!expr` for cleaner code.
2026-04-21 02:20:25 -04:00
bors c28e303778 Auto merge of #155552 - JonathanBrouwer:rollup-JKIpTuW, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#154654 (Move `std::io::ErrorKind` to `core::io`)
 - rust-lang/rust#145270 (Fix an ICE observed with an explicit tail-call in a default trait method)
 - rust-lang/rust#154895 (borrowck: Apply `user_arg_index` nomenclature more broadly)
 - rust-lang/rust#155213 (resolve: Make sure visibilities of import declarations make sense)
 - rust-lang/rust#155346 (`single_use_lifetimes`: respect `anonymous_lifetime_in_impl_trait`)
 - rust-lang/rust#155517 (Add a test for Mach-O `#[link_section]` API inherited from LLVM)
 - rust-lang/rust#155549 (Remove some unnecessary lifetimes.)
 - rust-lang/rust#154248 (resolve :  mark repr_simd as internal)
 - rust-lang/rust#154772 (slightly optimize the `non-camel-case-types` lint)
 - rust-lang/rust#155541 (Add `#[rust_analyzer::prefer_underscore_import]` to the traits in `rustc_type_ir::inherent`)
 - rust-lang/rust#155544 (bootstrap: Make "detected modifications" for download-rustc less verbose)
2026-04-20 16:15:13 +00:00
Lars Schumann 2ba7b3b537 constify vec comparisons 2026-04-20 16:00:18 +00:00
Tshaka Lekholoane 339a2f0ba0 Implement const Default for &CStr 2026-04-20 17:40:30 +02:00
aisr 0bfdb18855 add safety sections to two unsafe methods in NonZero 2026-04-20 22:46:10 +08:00
Nivekithan 6b8cb42ee3 update doc to be more clear 2026-04-20 18:55:05 +05:30
Jonathan Brouwer 7162558809 Rollup merge of #154248 - lms0806:issue_154034, r=TaKO8Ki
resolve :  mark repr_simd as internal

I changed ```repr_simd``` to ```internal``` and changed the position to ```feature-group-start: internal feature gates```.

close rust-lang/rust#154034
2026-04-20 13:52:07 +02:00
Trevor Gross 90a0227843 support: Update vendored cfg-if to upstream for true and false support
Link: https://github.com/rust-lang/cfg-if/commit/15aec4a67e633254e726bf477b8b86c65687bfc6
2026-04-20 07:08:20 -04:00
Zac Harrold fe2b39f064 Move std::io::ErrorKind to core::io
Move `std::io::ErrorKind` to `core::io`
* Update `rustdoc-html` tests for the new path
* Add `core_io` feature to control stability. This replaces the use of `core_io_borrowed_buf` on the `core::io` module itself.
* Re-export `core::io::ErrorKind` in `std::io::error`
2026-04-20 18:38:25 +10:00
Jonathan Brouwer 2e5a9fc307 Rollup merge of #155531 - Jules-Bertholet:is_ascii_punctuation_docs, r=scottmcm
Tweak `is_ascii_punctuation()` docs wording

These methods return `true` for characters with Unicode general category of punctuation (P), but also for those with general category of symbol (S).

@rustbot label A-docs
2026-04-20 08:14:14 +02:00
Jonathan Brouwer ede69dad7d Rollup merge of #155493 - sorairolake:fix-alignment-doc-link, r=scottmcm
docs(num): fix stale link to `mem::Alignment`

This pull request updates a stale link to `mem::Alignment` in `num::IntErrorKind`.

In rust-lang/rust#153178, I added a link to `Alignment` in `IntErrorKind`, but I overlooked that `Alignment` had been moved from `core::ptr` to `core::mem`. Although it is still re-exported in `core::ptr`, this pull request points the link to its canonical location.

@rustbot label +A-docs
2026-04-20 08:14:13 +02:00
Jonathan Brouwer 26f47ae831 Rollup merge of #154664 - okaneco:integer_cast_extras, r=scottmcm
core/num: Implement feature `integer_cast_extras`

Tracking issue https://github.com/rust-lang/rust/issues/154650
Accepted ACP https://github.com/rust-lang/libs-team/issues/765#issuecomment-4164285847

Implement `saturating`, `checked`, and `strict` casting between signed and unsigned integer primitives of the same bit-width.

Add `cast_integer` panic function to `overflow_panic.rs`
2026-04-20 08:14:11 +02:00
Jonathan Brouwer ce91732a75 Rollup merge of #155054 - Lars-Schumann:const-vec-ops, r=dtolnay
constify `Index(Mut)`, `Deref(Mut)` for `Vec`

Relevant tracking issues
const_convert: https://github.com/rust-lang/rust/issues/143773
const_index: https://github.com/rust-lang/rust/issues/143775
2026-04-20 08:14:09 +02:00
Jules Bertholet fd65209a77 Tweak is_ascii_punctuation()/graphic() docs wording
The `_punctuation` methods return `true` for characters with
Unicode general category of punctuation (P),
but also for those with general category
of symbol (S).
2026-04-19 22:27:16 -04:00
🍌Shawn e1059f6e53 Fix redundant boolean comparison in Mutex::try_lock 2026-04-20 09:49:52 +08:00
Zac Harrold 6960e7c958 Adjust usage of std::io::ErrorKind to be core compatible
* Checking exhaustion will no longer be possible for `repr_bitpacked`. Moving `kind_from_prim` into an associated function, and setting it up to be moved into `core::io` as well.
* `ErrorKind::as_str` is private, but it's only usage is trivially replaced with `Display::fmt`
* The features io_error_inprogress, io_error_more, and io_error_uncategorized will all need to be enabled
2026-04-20 08:29:15 +10:00