Commit Graph

7676 Commits

Author SHA1 Message Date
Chris Denton
07a28ec2fb
Rollup merge of #140081 - Berrysoft:update-libc-172, r=tgross35
Update `libc` to 0.2.172

r? ````@joboet````
2025-04-22 01:22:13 +00:00
bors
d6c1e454aa Auto merge of #140127 - ChrisDenton:rollup-2kye32h, r=ChrisDenton
Rollup of 11 pull requests

Successful merges:

 - #134213 (Stabilize `naked_functions`)
 - #139711 (Hermit: Unify `std::env::args` with Unix)
 - #139795 (Clarify why SGX code specifies linkage/symbol names for certain statics)
 - #140036 (Advent of `tests/ui` (misc cleanups and improvements) [4/N])
 - #140047 (remove a couple clones)
 - #140052 (Fix error when an intra doc link is trying to resolve an empty associated item)
 - #140074 (rustdoc-json: Improve test for auto-trait impls)
 - #140076 (jsondocck: Require command is at start of line)
 - #140107 (rustc-dev-guide subtree update)
 - #140111 (cleanup redundant pattern instances)
 - #140118 ({B,C}Str: minor cleanup)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-21 19:28:16 +00:00
Chris Denton
8ecaf148e7
Rollup merge of #140111 - jogru0:redundant_pattern, r=compiler-errors
cleanup redundant pattern instances

Just two small code cleanups.
2025-04-21 18:53:20 +00:00
Chris Denton
cac8bc3d1f
Rollup merge of #139795 - jethrogb:jb/sgx-linkage-comments, r=joboet
Clarify why SGX code specifies linkage/symbol names for certain statics

Specifying linkage/symbol name is solely to ensure a single instance between the `std` crate and its unit tests.

Also update the symbol names as items have moved around a bit. The actual name isn't that important, it just needs to be unique. But for debugging it can be useful for it to point to the right place.
2025-04-21 18:53:16 +00:00
Chris Denton
5779843eda
Rollup merge of #139711 - thaliaarchi:hermit-args, r=jhpratt
Hermit: Unify `std::env::args` with Unix

The only differences between these implementations of `std::env::args` are that Unix uses relaxed ordering, but Hermit uses acquire/release, and Unix truncates `argv` at the first null pointer, but Hermit doesn't. Since Hermit aims for Unix compatibility, unify it with Unix.

The atomic orderings were established in https://github.com/rust-lang/rust/pull/74006 (cc `@euclio)` for Unix and https://github.com/rust-lang/rust/pull/100579 (cc `@joboet)` for Hermit and, before those, they used mutexes and non-atomic statics. I think the difference in orderings is simply from them being changed at different times. The commented explanation for using acquire/release for Hermit is “to broadcast writes by the OS”. I'm not experienced enough with atomics to accurately judge, but I think acquire/release is stronger than needed. Either way, they should match.

Truncating at the first null pointer seems desirable, though I don't know whether it is necessary in practice on Hermit.

cc `@mkroening` `@stlankes` for Hermit
2025-04-21 18:53:16 +00:00
Chris Denton
24bd5649b1
Rollup merge of #140009 - ShE3py:tls-abort, r=thomcc
docs(LocalKey<T>): clarify that T's Drop shouldn't panic

Clarify that should a TLS destructor panics, the process will abort.

Also, an abort may be obfuscated as the process can be terminated with `SIGSEGV` or [`STATUS_STACK_BUFFER_OVERRUN`](https://devblogs.microsoft.com/oldnewthing/20190108-00/?p=100655) (i.e., `SIGABRT` is not guaranteed), so explicitly prints that the process was aborted.

Context:
https://users.rust-lang.org/t/status-stack-buffer-overrun-on-windows-without-any-usage-of-unsafe/128417

``@rustbot`` label -T-compiler
2025-04-21 15:55:57 +00:00
Chris Denton
10e17dc3a4
Rollup merge of #139982 - coolreader18:time-doc-tweak, r=jhpratt
SystemTime doc tweaks

* Change the `UNIX_EPOCH` link in the `SystemTime` docs to point to the associated constant, not the module level constant. The former seems to be the recommended way to access it, since aiui the only reason the module constant exists in the first place is that associated constants weren't stable yet at the time.
* Reword the comment in the `SystemTime` example - "an error occurred!" is a tad misleading; I feel like it implies a system error out of our control while `SystemTimeError` is more of a logic error.

I was originally just gonna do the first thing but I noticed the second and figured I may as well.

I'm also somewhat surprised that there aren't more in-depth module level docs for `std::time`; they don't even mention `SystemTime` at all. I might make another PR for that but mainly just wanted to flag it.
2025-04-21 15:55:57 +00:00
Jonathan Gruner
2039b36f90 cleanup redundant pattern instances 2025-04-21 14:15:32 +02:00
王宇逸
6ea0fe5fc4 Update libc to 0.2.172 for std 2025-04-20 21:19:52 +08:00
bors
49e5e4e3a5 Auto merge of #140043 - ChrisDenton:rollup-vwf0s9j, r=ChrisDenton
Rollup of 8 pull requests

Successful merges:

 - #138934 (support config extensions)
 - #139091 (Rewrite on_unimplemented format string parser.)
 - #139753 (Make `#[naked]` an unsafe attribute)
 - #139762 (Don't assemble non-env/bound candidates if projection is rigid)
 - #139834 (Don't canonicalize crate paths)
 - #139868 (Move `pal::env` to `std::sys::env_consts`)
 - #139978 (Add citool command for generating a test dashboard)
 - #139995 (Clean UI tests 4 of n)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-20 02:08:02 +00:00
Chris Denton
709f4fee50
Rollup merge of #139868 - thaliaarchi:move-env-consts-pal, r=joboet
Move `pal::env` to `std::sys::env_consts`

Combine the `std::env::consts` platform implementations as a single file. Use the Unix file as the base, since it has 28 entries, and fold the 8 singleton platforms into it. The Unix file was roughly grouped into Linux, Apple, BSD, and everything else, roughly in alphabetical order. Alphabetically order them to make it easier to maintain and discard the Unix-specific groups to generalize it to all platforms.

I'd prefer to have no fallback implementation, as I consider it a bug; however TEEOS, Trusty, and Xous have no definitions here. Since they otherwise have `pal` abstractions, that indicates that there are several platforms without `pal` abstractions which are also missing here. To support unsupported, create a little macro to handle the fallback case and not introduce ordering between the `cfg`s like `cfg_if!`.

I've named the module `std::sys::env_consts`, because they are used in `std::env::consts` and I intend to use the name `std::sys::env` for the combination of `Args` and `Vars`.

cc `@joboet` `@ChrisDenton`

Tracked in #117276.
2025-04-19 15:09:35 +00:00
Thalia Archibald
670ff84d1c Handle unsupported fallback 2025-04-18 19:49:23 -07:00
Thalia Archibald
37712cc016 Combine env consts into std::sys::env_consts 2025-04-18 19:17:08 -07:00
Thalia Archibald
e0d9244472 Sort Unix env constants alphabetically by target_os
They were roughly grouped into Linux, Apple, BSD, and everything else,
roughly in alphabetical order. Alphabetically order them to make it
easier to maintain and discard the Unix-specific groups to generalize it
to all platforms.
2025-04-18 16:35:26 -07:00
Patrick Mooney
fb3cae08ab std: Use fstatat() on illumos 2025-04-18 14:44:19 -05:00
bors
191df20fca Auto merge of #139996 - matthiaskrgr:rollup-0nka2hw, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138528 (deref patterns: implement implicit deref patterns)
 - #139393 (rustdoc-json: Output target feature information)
 - #139553 (sync::mpsc: prevent double free on `Drop`)
 - #139615 (Remove `name_or_empty`)
 - #139853 (Disable combining LLD with external llvm-config)
 - #139913 (rustdoc/clean: Fix lowering of fn params (fixes correctness & HIR vs. middle parity regressions))
 - #139942 (Ignore aix for tests/ui/erros/pic-linker.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-18 13:49:17 +00:00
Lieselotte
17b7d63fd7
rtprintpanic: clarify that the error is aborting the process 2025-04-18 15:02:22 +02:00
Lieselotte
0d56e3eed1
LocalKey<T>: document that the dtor should not panic 2025-04-18 14:11:32 +02:00
Matthias Krüger
af61fdf7d5
Rollup merge of #139934 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.155

Includes the following changes:

* Replace `#[naked]` with `#[unsafe(naked)]` [1] [2]
* Replace `bl!` with `asm_sym` [3]

[1]: https://github.com/rust-lang/compiler-builtins/pull/817
[2]: https://github.com/rust-lang/compiler-builtins/pull/821
[3]: https://github.com/rust-lang/compiler-builtins/pull/820

try-job: armhf-gnu
try-job: aarch64-apple
try-job: dist-apple-various
2025-04-18 05:17:53 +02:00
Matthias Krüger
5e8bc7f4d3
Rollup merge of #139553 - petrosagg:channel-double-free, r=RalfJung,tgross35
sync::mpsc: prevent double free on `Drop`

This PR is fixing a regression introduced by #121646 that can lead to a double free when dropping the channel.

The details of the bug can be found in the corresponding crossbeam PR https://github.com/crossbeam-rs/crossbeam/pull/1187
2025-04-18 05:16:29 +02:00
Trevor Gross
7d6f41b08e Update compiler-builtins to 0.1.155
Includes the following changes:

* Replace `#[naked]` with `#[unsafe(naked)]` [1] [2]
* Replace `bl!` with `asm_sym` [3]

[1]: https://github.com/rust-lang/compiler-builtins/pull/817
[2]: https://github.com/rust-lang/compiler-builtins/pull/821
[3]: https://github.com/rust-lang/compiler-builtins/pull/820
2025-04-17 19:08:27 +00:00
Noa
34573d683f
Be more specific about the error in the SystemTime example 2025-04-17 11:57:28 -05:00
Noa
88bd1913f2
Point UNIX_EPOCH to associated constant in SystemTime docs 2025-04-17 11:37:54 -05:00
Matthias Krüger
f14e632270
Rollup merge of #139667 - 1c3t3a:remove-no-sanitize, r=m-ou-se
cfi: Remove #[no_sanitize(cfi)] for extern weak functions

Previously (https://github.com/rust-lang/rust/pull/115200, https://github.com/rust-lang/rust/pull/138002), we added `#[no_sanitize(cfi)]` to all code paths that call to a weakly linked function.

In https://github.com/rust-lang/rust/pull/138349 we fixed the root cause for this issue, which means we can now remove the corresponding attributes.

r? `@rcvalle`
2025-04-17 00:16:21 +02:00
Bastian Kersting
c4d3563554 Also remove the no_sanitize feature for std 2025-04-16 00:14:10 +02:00
Josh Triplett
043c5ff982 Add warning comment to Take::get_ref and Chain::get_ref
The methods `Take::get_mut` and `Chain::get_mut` include comments
warning about modifying the I/O state of the underlying reader. However,
many readers (e.g. `File`) allow I/O using a shared reference (e.g.
`&File`). So, add the same caveat to the `get_ref` methods.
2025-04-15 10:54:08 -07:00
Stuart Cook
783b08156e
Rollup merge of #139836 - glyn:test-mpmc-receiver-cloning, r=jhpratt
Basic tests of MPMC receiver cloning

Ref: https://github.com/rust-lang/rust/issues/126840#issuecomment-2802321146
2025-04-15 15:47:32 +10:00
Stuart Cook
45b644b3c1
Rollup merge of #139822 - 0x79de:fix-eopnotsupp-mapping, r=dtolnay
Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix

This change maps the EOPNOTSUPP errno value (95) to std::io::ErrorKind::Unsupported in the decode_error_kind function for Unix platforms. Previously, it was incorrectly mapped to ErrorKind::Uncategorized.

Fixes #139803
2025-04-15 15:47:31 +10:00
Stuart Cook
36df54881d
Rollup merge of #139750 - no1wudi:fix, r=tgross35
std/thread: Use default stack size from menuconfig for NuttX

* Update comments to clarify the usage of zero as an indication for default stack size configuration
* Adjust conditional compilation to reflect the changes in stack size handling for the NuttX platform

This change improves clarity and consistency in stack size configuration across platforms.
2025-04-15 15:47:28 +10:00
Stuart Cook
6a9d27d320
Rollup merge of #139554 - lolbinarycat:std-output-exit_ok, r=tgross35
std: add Output::exit_ok

approved in ACP https://github.com/rust-lang/libs-team/issues/554

Tracking issue: https://github.com/rust-lang/rust/issues/84908
2025-04-15 15:47:26 +10:00
Stuart Cook
46b197ad3b
Rollup merge of #139517 - Ayush1325:uefi-cmd-stdin-null, r=joboet
std: sys: process: uefi: Use NULL stdin by default

According to the docs in `Command::output`:

> By default, stdout and stderr are captured (and used to provide the
resulting output). Stdin is not inherited from the parent and any attempt by the child process to read from the stdin stream will result in the stream immediately closing.

This was being violated by UEFI which was inheriting stdin by default.

While the docs don't explicitly state that the default should be NULL, the behaviour seems like reading from NULL.

UEFI however, has a bit of a problem. The `EFI_SIMPLE_TEXT_INPUT_PROTOCOL` only provides support for reading 1 key press. This means that you either get an error, or it is assumed that the keypress was read successfully. So there is no way to have a successful read of length 0. Currently, I am returning UNSUPPORTED error when trying to read from NULL stdin. On linux however, you will get a read of length 0 for Null stdin.

One possible way to get around this is to translate one of the UEFI errors to a read 0 (Maybe unsupported?). It is also possible to have a non-standard error code, but well, not sure if we go that route.

Alternatively, if meaning of Stdio::Null is platform dependent, it should be fine to keep the current behaviour of returning an error.

cc ```@nicholasbishop``` ```@dvdhrm```
2025-04-15 15:47:25 +10:00
Glyn Normington
1376810d44 Basic tests of MPMC receiver cloning
Ref: https://github.com/rust-lang/rust/issues/126840#issuecomment-2802321146
2025-04-15 02:37:57 +01:00
binarycat
9676d4aeb7 std: add Output::exit_ok
approved in ACP https://github.com/rust-lang/libs-team/issues/554
2025-04-14 19:11:31 -05:00
0x79de
188d44dd6e Fix: Map EOPNOTSUPP to ErrorKind::Unsupported on Unix
This change maps the EOPNOTSUPP errno value (95) to std::io::ErrorKind::Unsupported in the decode_error_kind function for Unix platforms. Previously, it was incorrectly mapped to ErrorKind::Uncategorized.

Fixes #139803
2025-04-14 21:25:48 +03:00
Jethro Beekman
8dc773296c Clarify why SGX code specifies linkage/symbol names for certain statics
Also update the symbol names as items have moved around a bit. The actual
name isn't that important, it just needs to be unique. But for debugging
it can be useful for it to point to the right place.
2025-04-14 13:36:06 +02:00
Thalia Archibald
c1f0498e65 Hermit: Unify std::env::args with Unix
The only differences between these implementations are that Unix uses
relaxed ordering, but Hermit uses acquire/release, and Unix truncates
`argv` at the first null pointer, but Hermit doesn't. Since Hermit aims
for Unix compatibility, unify it with Unix.
2025-04-13 14:35:22 -07:00
Ayush Singh
d994fef749
std: sys: process: uefi: Allow specifying Stdin
Stdio::MakePipe is not supported.

For Stdio::Null, return UNSUPPORTED. This is treated as read(0).
Additionally, have infinte loop on the notify function to prevent
wait_for_key from returning.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-13 23:22:59 +05:30
Ayush Singh
af25995d11
std: sys: stdio: uefi: Tread UNSUPPORTED Status as read(0)
Allows implementing Stdio::Null for Command in a deterministic manner.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-13 23:22:59 +05:30
Ayush Singh
a404015775
std: sys: process: uefi: Use NULL stdin by default
According to the docs in `Command::output`:

> By default, stdout and stderr are captured (and used to provide the
resulting output). Stdin is not inherited from the parent and any attempt
by the child process to read from the stdin stream will result in the
stream immediately closing.

This was being violated by UEFI which was inheriting stdin by default.

While the docs don't explicitly state that the default should be NULL,
the behaviour seems like reading from NULL.

UEFI however, has a bit of a problem. The `EFI_SIMPLE_TEXT_INPUT_PROTOCOL`
only provides support for reading 1 key press. This means that you
either get an error, or it is assumed that the keypress was read
successfully. So there is no way to have a successful read of length 0.
Currently, I am returning UNSUPPORTED error when trying to read from
NULL stdin. On linux however, you will get a read of length 0 for Null
stdin.

One possible way to get around this is to translate one of the UEFI
errors to a read 0 (Maybe unsupported?). It is also possible to have a
non-standard error code, but well, not sure if we go that route.

Alternatively, if meaning of Stdio::Null is platform dependent, it
should be fine to keep the current behaviour of returning an error.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-04-13 23:22:58 +05:30
Huang Qi
15a93c5683 std/thread: Use default stack size from menuconfig for NuttX
* Update comments to clarify the usage of zero as an indication for default stack size configuration
* Adjust conditional compilation to reflect the changes in stack size handling for the NuttX platform

This change improves clarity and consistency in stack size configuration across platforms.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-04-13 21:19:09 +08:00
Chris Denton
daed9e2d9f
Rollup merge of #139710 - thaliaarchi:move-args-pal, r=joboet
Move `args` into `std::sys`

Move platform definitions of `args` into `std::sys`, as part of https://github.com/rust-lang/rust/issues/117276.

cc ``@joboet``
2025-04-13 11:48:19 +00:00
Chris Denton
8a6d6f5ae5
Rollup merge of #139683 - ChrisDenton:windows-with-native, r=tgross35,joboet
Use `with_native_path` for Windows

Ideally, each platform should use their own native path type internally. This will, for example, allow passing a UTF-16 string directly to `std::fs::File::open` and therefore avoid the need for allocating a new null-terminated wide string. However, doing that for every function and platform all at once makes for a large PR that is way too prone to breaking. So this just does some of the Windows parts.

As with the previous Unix PR (#138832) this is intended to be merely a refactoring so I've avoided anything that may require more substantial changes.
2025-04-13 11:48:18 +00:00
Chris Denton
9d2d6a040f
Rollup merge of #138972 - thaliaarchi:nuttx-build, r=Mark-Simulacrum
std: Fix build for NuttX targets

Fix std build for all NuttX targets. It is the single largest set of failures on <https://does-it-build.noratrieb.dev/>. Although, ESP-IDF also requires these same gates, there are other issues for those targets.

This can verified be running `x check library/std --target=` for all NuttX targets.

cc ``@no1wudi``
2025-04-13 11:48:15 +00:00
bors
65fa0ab924 Auto merge of #139734 - ChrisDenton:rollup-28qn740, r=ChrisDenton
Rollup of 6 pull requests

Successful merges:

 - #139107 (std: make `cmath` functions safe)
 - #139607 (Add regression test for #127424)
 - #139691 (Document that `opt-dist` requires metrics to be enabled)
 - #139707 (Fix comment in bootstrap)
 - #139708 (Fix name of field in doc comment)
 - #139709 (bootstrap: fix typo in doc string)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-13 07:10:43 +00:00
Chris Denton
5b2fd54829
Rollup merge of #139107 - joboet:safe_cmath, r=ibraheemdev
std: make `cmath` functions safe

The floating point intrinsics are more difficult, I'll probably wait until #119899 has merged before making them safe as well.
2025-04-13 03:07:06 +00:00
Chris Denton
e0f92bb53c
Rollup merge of #139688 - rust-lang:notriddle/io-result-unbox, r=GuillaumeGomez
rustdoc-search: add unbox flag to Result aliases

Fixes #139665
2025-04-12 21:05:30 +00:00
Chris Denton
096369d97f
Rollup merge of #139382 - ChrisDenton:windows-bindgen-0-61, r=Mark-Simulacrum
Update windows-bindgen to 0.61.0

This updates the automatically generate Windows API bindings. Not much changed this time:

- There's now `Default` implementations for many types, which is convenient. It does however conflict with one place where we implemented a non-zeroed default (to set the length field). But that's no big problem.
- The `--no-core` flag has been renamed to `--no-deps` to more accurately reflect its meaning (i.e. generate all necessary code without requiring additional dependencies).
- The `--link` flag allows us to set the location of the `link!` macro. Currently we use our workspace's `windows_targets` crate but we could move it into library/std using `--link`. However, this would need to be co-ordinated with the `backtrace` crate (which is a separate crate but included in std using `#[path]`). So I've left that for another time.
2025-04-12 21:05:29 +00:00
Chris Denton
0ea345a3c3
Rollup merge of #139276 - tgross35:enable-f16-without-neon, r=Mark-Simulacrum
Revert "Disable `f16` on Aarch64 without `neon`"

The LLVM issue [1] was resolved and the fix was synced to rust-lang/rust in [2].

This reverts commit c51b229140.

[1]: https://github.com/llvm/llvm-project/issues/129394
[2]: https://github.com/rust-lang/rust/pull/138695

try-job: aarch64-gnu
try-job: aarch64-gnu-debug
try-job: armhf-gnu
try-job: dist-various-1
2025-04-12 21:05:28 +00:00
Thalia Archibald
bea202253e Unify owned Args types between platforms 2025-04-12 05:11:27 -07:00
Thalia Archibald
e014fd6b87 Use unsupported args for espidf and vita 2025-04-12 04:38:20 -07:00