Commit Graph

9616 Commits

Author SHA1 Message Date
Jacob Pratt
9e0b9bc6cd Rollup merge of #158885 - folkertdev:complex-layout, r=workingjubilee
Add `core::num::Complex`

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

See also [#t-compiler > representing `_Complex`](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/representing.20.60_Complex.60/with/608308993). The RFC states that the `Complex` type should match the ABI of `_Complex` in C, but provides little detail on how to actually achieve this. We concluded that `repr(complex)` is probably the best approach. Like clang, that means we "desugar" the representation early: `_Complex` is not natively represented in LLVM IR.

I've derived the ABI from `clang` for 28 targets, a decent sample of what we actually support. For now I'm only actually testing `x86_64` because (as you'll see) updating the tests is quite labor-intensive. If we're happy with this direction I can fill more of them in, likely in a separate PR.

The libs side of the type is very bare-bones: I'm not as interested in that part. Others can fill in the various instances, methods, write tests for those, and improve the docs.

r? workingjubilee
2026-08-13 18:16:12 -04:00
Jacob Pratt
11c37a33bc Rollup merge of #161037 - joboet:main_altstack, r=clarfonthey
std: don't clean up the main thread's altstack

Fixes rust-lang/rust#161018

https://github.com/rust-lang/rust/pull/28069 added a call to what is now `rt::cleanup` to `process::exit`. `rt::cleanup` in turn calls the UNIX `stack_overflow::cleanup`, which frees the main thread's signal stack and uninstalls the current thread's signal handler in the assumption that the current thread is the main one – even though `process::exit` can be called from any thread.

This PR removes the main thread cleanup logic altogether, since, as the FIXME in `stack_overflow::cleanup` points out, it causes more issues than it is worth. This also means that stack overflows in TLS destructors will be caught on the main thread, partly addressing rust-lang/rust#111272.
2026-08-13 18:16:10 -04:00
Jacob Pratt
a4ce93b217 Rollup merge of #160972 - valentynkit:windows-seek-invalid-input, r=JohnTitor
std: map ERROR_NEGATIVE_SEEK to ErrorKind::InvalidInput on Windows

Windows error mapping doesn't have an arm for `ERROR_NEGATIVE_SEEK`, the code returned when using negative seek position, so it decodes to `ErrorKind::Uncategorized`.

On unix negative seek is `EINVAL`:
[> EINVAL whence is not valid.  Or: the resulting file offset would be negative, or beyond the end of a seekable device.](https://www.man7.org/linux/man-pages/man2/lseek.2.html)
And is mapped to [InvalidInput](e64c8a664d/library/std/src/sys/io/error/unix.rs (L154)) error.

On Windows there is `ERROR_NEGATIVE_SEEK` [windows_sys.rs#L1829](e64c8a664d/library/std/src/sys/pal/windows/c/windows_sys.rs (L1829)).

The message on Windows would still be more specific and detailed for this error. Both messages come from the OS itself, so not sure if it could be addressed somehow. Looks like Unix has more coarse error codes than Windows, which uses more granular ones with more precise messages: `EINVAL` is shared across many syscalls, so its message is more general.

Windows:
`kind: InvalidInput, message: "An attempt was made to move the file pointer before the beginning of the file."`
Unix:
`kind: InvalidInput, message: "Invalid argument" `

Fixes rust-lang/rust#158246

r? libs
2026-08-13 18:16:06 -04:00
Jacob Pratt
633031af6a Rollup merge of #160440 - bjorn3:refactor_unwind4, r=Mark-Simulacrum
Couple of misc improvements to the unwind infrastructure

* Fix `_Unwind_Exception` size on Emscripten.
* Move a link block.
* Remove some manual dummy impls where there is already a dummy fallback.

Follow up to https://github.com/rust-lang/rust/pull/159785
2026-08-13 18:16:04 -04:00
Jacob Pratt
b5bd6182b6 Rollup merge of #157428 - nia-e:allocator-refactor, r=clarfonthey
allocator: refactor for stabilisation

Adds my current proposal per the doc in rust-lang/rust#156882 and follow-up Zulip conversations (notably for [dyn-compat](https://rust-lang.zulipchat.com/#narrow/channel/197181-t-libs.2Fwg-allocators/topic/Allocator.20dyn-safety/near/599555822)) unstably.

r? libs
2026-08-13 18:16:00 -04:00
joboet
79747699c5 std: don't clean up the main thread's altstack 2026-08-13 10:56:02 +02:00
bors
1e5ee35637 Auto merge of #161014 - jhpratt:rollup-lyWH2E3, r=jhpratt
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#160976 (Ensure TLS accesses don't call the global allocator through panic (part 2))
 - rust-lang/rust#160438 ([rustdoc] Change table odd table rows background color to not make it the same as inline code)
 - rust-lang/rust#160985 (self-profile more of borrowck)
 - rust-lang/rust#137858 (Add new `unused_footnote_definition` rustdoc lint)
 - rust-lang/rust#159566 (Add support for generics in `offload`and remove `no_mangle` attribute)
 - rust-lang/rust#160676 (rustc_public: split `def`s out of `ty`)
 - rust-lang/rust#160861 (rustc_parse: suggest removing semicolon before `if` block)
 - rust-lang/rust#160958 (Remove unused `#[non_exhaustive]` in library)
 - rust-lang/rust#160978 (move resolve_path to Session inherent method)
 - rust-lang/rust#160990 (Remove old cfg parser which is now dead code)
 - rust-lang/rust#160991 (Add offload component on nightly)
 - rust-lang/rust#160999 (doc changes to expect messages in process.rs)
 - rust-lang/rust#161003 (Also warn if an invalid `doc` attribute is used on a macro invocation)
2026-08-13 07:24:48 +00:00
Jacob Pratt
8e38ef5262 Rollup merge of #160999 - dronavallipranav:compliant-expect-error-messages, r=nia-e
doc changes to expect messages in process.rs

Reword expect messages in `library/std/src/process.rs` to follow style guide rust-lang/rust#96033

Example
```diff
- child.wait().expect("command wasn't running");
+ child.wait().expect("wait on child should succeed")
```

Issue: rust-lang/rust#159751
2026-08-12 20:17:36 -04:00
Jacob Pratt
ecc1bbebbf Rollup merge of #160958 - mu001999-contrib:remove-unused-non-exhaustive, r=oli-obk
Remove unused `#[non_exhaustive]` in library

Extracted from https://github.com/rust-lang/rust/pull/160918
2026-08-12 20:17:33 -04:00
Pranav Dronavalli
795555e778 doc changes to expect messages in process.rs
* doc changes to expect messages in process.rs
* req changes for expect message
2026-08-12 22:51:13 +00:00
bors
52d0866480 Auto merge of #160953 - ChrisDenton:clippy, r=nia-e
Enforce more library clippy lints in CI



Best reviewed commit by commit.

This is testing the waters for enforcing more clippy lints. I've chosen these ones because we mostly adhere to them already (at least in core/alloc/std) so we can reduce the noise in `./x clippy` by fixing or allowing the relatively few violations.
2026-08-12 21:24:01 +00:00
Folkert de Vries
5b66cc1ab2 add Complex type 2026-08-12 22:50:00 +02:00
Chris Denton
3691df7e3c Ignore backtrace-rs clippy failures 2026-08-12 19:14:57 +00:00
Chris Denton
c3c4d1f3fb clippy::empty_line_after_doc_comments 2026-08-12 19:14:56 +00:00
Chris Denton
6dab6042c7 clippy::needless_return 2026-08-12 19:11:35 +00:00
Chris Denton
2a57d04b6e clippy::let_and_return 2026-08-12 19:11:34 +00:00
Chris Denton
2536dc4e77 clippy::len_zero 2026-08-12 19:11:33 +00:00
Chris Denton
c71d9461bf clippy::legacy_numeric_constants 2026-08-12 19:11:32 +00:00
Max Dexheimer
5b7132497c Ensure TLS accesses don't call the global allocator through panic part 2
This is torture.
2026-08-12 20:42:35 +02:00
Valentyn Kit
78f89807d6 std: map ERROR_NEGATIVE_SEEK to ErrorKind::InvalidInput on Windows
Windows error mapping doesn't have an arm for `ERROR_NEGATIVE_SEEK`,
the code returned when using negative seek position, so it
decodes to `ErrorKind::Uncategorized`. Unix already maps the equivalent
`EINVAL` to `InvalidInput`

This adds the missing arm, on Windows to match with Unix.
2026-08-12 19:17:30 +03:00
bjorn3
e08ce7fbbb Avoid defining dummy personality function for Motor OS 2026-08-12 17:28:06 +02:00
Roland Xu
a184a6dd42 Remove unused #[non_exhaustive] in library 2026-08-12 11:07:56 +08:00
Jacob Pratt
33ca9580c9 Rollup merge of #160934 - maxdexh:fix-thread-local-global-alloc-reenter, r=nia-e
Ensure TLS accesses don't call the global allocator through panic

Fixes rust-lang/rust#160930

That issue is much more simple to fix than the other reentrancy issues, since only thread locals
use the TLS code. We can just replace all the assertions with their `rt` versions that do not
call the global allocator.

r? libs
2026-08-11 21:18:31 -04:00
Jacob Pratt
60365e5144 Rollup merge of #160868 - alexcrichton:adjust-wasi-tls-again, r=clarfonthey
std: Adjust cfgs again for TLS on WASI

This commit adjusts the changes made in rust-lang/rust#159733. A wasi-libc bug was discovered in rust-lang/rust#160828 which is present in certain situations which means that the changes in rust-lang/rust#159733 expose this bug. The purpose of this PR is to get wasip1/wasip2 targets fixed again while preserving a working implementation for wasip3. This upstream bug is already fixed in wasi-libc meaning that this PR won't be necessary once wasi-sdk-34 is published and used in rust-lang/rust. Until that time, however, this effectively reverts rust-lang/rust#159733 for wasip1/wasip2. The wasip3 target is Tier 3 still and requires wasi-sdk-34 anyway which is why that's left unchanged.

Closes rust-lang/rust#160828
2026-08-11 21:18:25 -04:00
Max Dexheimer
16c05747bc Ensure TLS accesses don't call the global allocator through panic 2026-08-11 20:13:17 +02:00
Jacob Pratt
80fdf73bad Rollup merge of #160881 - malezjaa:implement_new_init, r=clarfonthey
Implement <OnceCell,OnceLock>::new_init

Tracking issues: rust-lang/rust#159859 rust-lang/rust#159860

I'm not sure If I was supposed to add any other tests apart from the doc tests.
2026-08-10 23:49:39 -04:00
malezjaa
34b02c630a implement <OnceCell,OnceLock>::new_init 2026-08-11 00:46:20 +02:00
Alex Crichton
dd905cd111 std: Adjust cfgs again for TLS on WASI
This commit adjusts the changes made in 159733. A wasi-libc bug was
discovered in 160828 which is present in certain situations which means
that the changes in 159733 expose this bug. The purpose of this PR is
to get wasip1/wasip2 targets fixed again while preserving a working
implementation for wasip3. This upstream bug is already fixed in
wasi-libc meaning that this PR won't be necessary once wasi-sdk-34 is
published and used in rust-lang/rust. Until that time, however, this
effectively reverts 159733 for wasip1/wasip2. The wasip3 target is Tier
3 still and requires wasi-sdk-34 anyway which is why that's left
unchanged.

Closes 160828
2026-08-10 10:48:44 -07:00
Jonathan Brouwer
db9e32700a Rollup merge of #160825 - vita-rust:fix-references-unsupported-vita, r=joboet
Fix references to unsupported on sys::paths::unix

Compilation was seemingly broken by PR https://github.com/rust-lang/rust/pull/150885, commit f2dd93228a, by removing one of the nested `mod`s.

I'm one of the `armv7-sony-vita-newlibeabihf` target maintainers.

Summary of changes for affected targets:

- `armv7-sony-vita-newlibeabihf`: now compiles
- `armv6k-nintendo-3ds`: still doesn't compile, apparently due to an issue introduced in https://github.com/rust-lang/rust/pull/158168, which should be fixed by https://github.com/rust-lang/rust/pull/160170
- all espidf targets: I haven't compiled any of them as I don't have the toolchain installed, but it should be on the same as 3DS. The same errors can be seen in [does-it-build](https://does-it-build.noratrieb.dev/build?nightly=2026-08-09&target=xtensa-esp32s3-espidf&mode=std)
2026-08-10 19:02:06 +02:00
Aphek
57e48b0196 Fix references to unsupported on sys::paths::unix
These were broken by PR https://github.com/rust-lang/rust/pull/150885,
commit f2dd93228a
2026-08-09 21:40:01 -03:00
Mark Rousskov
7253b2ba61 Stabilize fs_set_times
This stabilizes both functions under this feature gate:

* `std::fs::set_times`
* `std::fs::set_times_nofollow`
2026-08-09 18:26:24 -04:00
Nia Deckers
f4d4ee7489 allocator: refactor for stabilisation
yk what we can do btree later

raaaaagh

pain and suffering

*unleaks your box* whats thiSegmentation fault (core dumped)

straight up testing it. and by it,

well, let's just say. "my allocator"

linked and listed

the unnecesary bits? gone. reduced to atoms
2026-08-09 17:37:43 +02:00
Jed McKenna
efdcd0d725 Changed .expect error message in documentation to follow “expect as precondition” style. 2026-08-09 16:51:06 +10:00
Jonathan Brouwer
473809d9da Rollup merge of #157609 - guoxe:fix_build_std_arm32_gnu_time_bits64, r=Mark-Simulacrum
fix: build-std on 32 bit arm with 64 bit time

Infer target type of `tv_usec`.

The libc crate has support for building with 64 bit time on 32 bit
platforms, configurable currently via environment variable or cfg directives.
When building using 64 bit time, the tv_usec field will be aliased to `__suseconds64_t` instead of `suseconds_t` causing the `build-std` feature to not be able to build the standard library due to a type mismatch.
Adopting the same convention as in 1b29cfdbee/library/std/src/sys/net/connection/socket/solid.rs (L151) fixes the issue, supporting 64 bit time on 32 bit arm platforms.

Another option would be using cfg attributes for this but from what I can tell there are no existing such attributes for time bits in the std and they would essentially duplicate the ones already present in the libc crate e27c7f1e2b/build.rs (L16)
2026-08-08 16:32:44 +02:00
Gustaf Oxenstierna
f846f116fd fix: build-std on 32 bit arm with 64 bit time
* fix: build-std on 32 bit arm with 64 bit time

The libc crate has support for building with 64 bit time on 32 bit
platforms using the `RUST_LIBC_UNSTABLE_GNU_TIME_BITS` environment
variable.

Convert the tv_usec field to i64 via `into` in this case since
`suseconds_t` is still defined as an i32 when this environment variable
is set.
* Use placeholder as target type

This allows us to rely on the compiler to infer the correct target type,
mirroring the approach used in `sys/net/connection/socket/solid.rs`.
2026-08-08 13:50:34 +00:00
Jonathan Brouwer
4eeee3b756 Rollup merge of #150885 - farao:main, r=saethlin,joboet
Revive L4Re target

This revives the target for the L4Re OS. It changes the way, linking is done and adds aarch64 support and documentation including a maintainer for the target.

The update of the libc crate is necessary since only in 0.2.179 and higher is the fixed support for L4Re on uclibc.
2026-08-08 00:38:20 +02:00
Marius Melzer
f2dd93228a L4Re: Repair build and move to rustc linking
Fixes the builds of rustc and library/std for the L4Re target OS.
A major change was done in linking binaries: The need for the L4Bender
tool was removed and linking parameters are now fully configured in the
rustc target config.
2026-08-06 13:13:18 +02:00
Jonathan Brouwer
bb0f117b56 Rollup merge of #159530 - devnexen:gh115325, r=Darksonn
Cap socket send length to c_int::MAX on Apple targets

On Apple, `send`/`sendto` reject a length larger than `c_int::MAX` with `EINVAL` instead of doing a short send. The send length was only clamped to `wrlen_t::MAX` (a no-op on 64-bit unix), so writing more than `c_int::MAX` bytes to a socket failed on macOS.

Add a `MAX_SEND_LEN` cap (`c_int::MAX` on Apple, `wrlen_t::MAX` elsewhere), used in `write`, `send`, `send_to`, and `send_with_flags`.

Fixes rust-lang/rust#115325
2026-08-06 12:40:57 +02:00
Jonathan Brouwer
a5fb91ec03 Rollup merge of #159014 - GuillaumeGomez:doc-cfg-filter-doctest, r=Urgau
[rustdoc] Do not take `doc(cfg())` into account when filtering doctests

Part of rust-lang/rust#147033.

Because it was using the `extract_cfg_from_attrs` common function, it was taking into account the `doc(cfg())` attributes the same as if they were a `cfg`.

I didn't mark this PR as "fix" because I didn't handle the case of the doctest not being marked as ignored because I'm not sure if we should revisit the fact that we ignore these doctests or if we should just mark them as ignored (because of `target_feature(enable = "...")`).

Setting @fmease as reviewer as they are likely the only one with context about this issue. 😆

r? @fmease
2026-08-05 21:55:41 +02:00
Guillaume Gomez
49dae43280 Fix cfg_attr for library/std/src/os/unix/net/ancillary.rs 2026-08-05 17:09:08 +02:00
Guillaume Gomez
d6132d014c Add missing cfg_attr on doc tests in stdlib os module 2026-08-05 17:07:52 +02:00
Guillaume Gomez
f1ea79cc1c Fix new windows doc code example 2026-08-05 17:07:52 +02:00
Guillaume Gomez
338d346002 Ignore std doctests if not run on the right OS 2026-08-05 17:07:52 +02:00
Jonathan Brouwer
4cbd5dcdd0 Rollup merge of #160538 - CacinieP:expect-tcp-precondition-style, r=jhpratt
Update expect messages in tcp.rs doc examples to follow the style guide

Related issue: rust-lang/rust#159751

Rewords the `.expect(...)` messages in the `TcpStream`/`TcpListener` doc examples in `library/std/src/net/tcp.rs` to follow the "expect as precondition" style guide introduced in rust-lang/rust#96033.

Examples of the change:
- `"set_nodelay call failed"` → `"set_nodelay should succeed"`
- `"could not set TTL"` → `"set_ttl should succeed"`
- `"Cannot set non-blocking"` → `"set_nonblocking should succeed"`

19 doc-example messages updated, all in doc comments (`///`). Doc-only change, no behavior change.
2026-08-05 13:36:20 +02:00
Jonathan Brouwer
8c6b914cec Rollup merge of #158762 - vexide:feat/vex-v5-thumb2, r=jieyouxu
Emit thumb code on VEX V5

This PR switches the default codegen for the VEX V5 target to emit Thumb-2 instructions, allowing for smaller binary sizes (on the programs I tested this change on, I saw a ~20% size decrease on average). The target is renamed to have the `thumb` prefix instead of the `arm` prefix because of the updated instruction set.

Since VEXos starts all programs in Arm32 mode, the program entrypoint is explicitly compiled as ARM code and now transitions to Thumb mode when calling `_start`.

Users can still use the updated target in Arm32 mode by specifying `-Ctarget-feature=-thumb-mode`.

cc @tropicaaal @Gavin-Niederman
2026-08-05 13:36:10 +02:00
Jonathan Brouwer
ae817ec4a9 Rollup merge of #158726 - valentynkit:sys-sync-futex, r=jhpratt
std: move futex implementations into sys::sync::futex

Part of rust-lang/rust#117276.

Moves the futex primitives out of the per-platform `sys::pal` modules into a single `sys::sync::futex`, selected with `cfg_select!` the same way the other `sys::sync` backends are.
Every consumer of these primitives already lives in `sys::sync` (mutex, rwlock, once, condvar, thread_parking), so they now import `crate::sys::sync::futex` directly instead of reaching `crate::sys::futex` through the `pub use pal::*` glob.

I placed it under `sys::sync` rather than a top-level `sys::futex` because the futex API only backs the `sys::sync` primitives and sits next to the existing `sys::sync::thread_parking` backend.

Happy to place it to `sys::futex` if you would rather have it as a peer of the other feature modules.

The file moves are a separate commit, recorded in `.git-blame-ignore-revs` so blame skips the rename.

r? joboet
2026-08-05 13:36:10 +02:00
Jonathan Brouwer
ebab4cfd9a Rollup merge of #158147 - devnexen:windows_fs_oflow_fix, r=Darksonn
std: fix stack buffer overflow in Windows junction_point

The guard checked `data_len > u16::MAX`, allowing paths far larger than `PathBuffer` (a fixed 16384-element array), which the subsequent single `copy_from` then overflows. Bound against `MAXIMUM_REPARSE_DATA_BUFFER_SIZE` plus header instead, matching the kernel's limit.
2026-08-05 13:36:03 +02:00
David Carlier
08f76ddaad Share the zeroed-mmap test buffer between the TCP and UDP tests
The pages are demand-zero and never written, so the datagram test no
longer needs ~2 GiB of memory and its `#[ignore]` can go away. Keep a
`Vec`-backed copy for non-unix targets, where `mmap` isn't available.
2026-08-05 10:37:56 +01:00
David Carlier
6477fb5871 address feedbacks 2026-08-05 10:23:23 +01:00
David Carlier
28e1c851ad Add test for oversized datagram sends 2026-08-05 10:23:23 +01:00