about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-01-27Rollup merge of #135876 - usamoi:mpmc-doc, r=tgross35Guillaume Gomez-4/+12
fix doc for std::sync::mpmc fix document of `std::sync::mpmc` (tracked in https://github.com/rust-lang/rust/issues/126840)
2025-01-27Overhaul examples for PermissionsExtMarijn Schouten-49/+75
This fixes #91707 by including one overarching example, instead of the small examples that can be misleading.
2025-01-27fix doc for std::sync::mpmcusamoi-4/+12
2025-01-27Rollup merge of #135635 - tbu-:pr_io_pipe, r=joboetLeón Orell Valerian Liehr-272/+281
Move `std::io::pipe` code into its own file Also update the docs for the new location, create a section "Platform-specific behavior", don't hide required imports for code examples.
2025-01-26Auto merge of #136087 - jhpratt:rollup-tam1mzn, r=jhprattbors-10/+3
Rollup of 7 pull requests Successful merges: - #133631 (Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only)) - #134358 (compiler: Set `target_abi = "ilp32e"` on all riscv32e targets) - #135812 (Fix GDB `OsString` provider on Windows ) - #135842 (TRPL: more backward-compatible Edition changes) - #135946 (Remove extra whitespace from rustdoc breadcrumbs for copypasting) - #135953 (ci.py: check the return code in `run-local`) - #136019 (Add an `unchecked_div` alias to the `Div<NonZero<_>>` impls) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-26Test pipes also when not running on Windows and Linux simultaneouslyTobias Bucher-1/+1
Fixes https://github.com/rust-lang/rust/pull/135635#pullrequestreview-2574184488.
2025-01-26Update `std::io::{pipe, PipeReader, PipeWriter}` docs the new locationTobias Bucher-16/+20
Also create a section "Platform-specific behavior", don't hide required imports for code examples.
2025-01-26Move `std::io::pipe` code into its own fileTobias Bucher-272/+277
2025-01-26Move std::sync unit tests to integration testsbjorn3-4130/+8
This removes two minor OnceLock tests which test private methods. The rest of the tests should be more than enough to catch mistakes in those private methods. Also makes ReentrantLock::try_lock public. And finally it makes the mpmc tests actually run.
2025-01-26Move std::thread_local unit tests to integration testsbjorn3-422/+0
2025-01-26Move std::time unit tests to integration testsbjorn3-277/+0
2025-01-26Move std::path unit tests to integration testsbjorn3-2082/+0
2025-01-26Move std::panic unit tests to integration testsbjorn3-59/+0
2025-01-26Move std::num unit tests to integration testsbjorn3-233/+0
2025-01-26Move std float unit tests to integration testsbjorn3-3813/+0
2025-01-26Move std::error unit tests to integration testsbjorn3-447/+0
2025-01-26Move std::env unit tests to integration testsbjorn3-123/+0
2025-01-26Rollup merge of #133631 - flba-eb:add_nto_qnx71_iosock_support, r=workingjubileeJacob Pratt-10/+3
Support QNX 7.1 with `io-sock`+libstd and QNX 8.0 (`no_std` only) Changes of this pull request: 1. Refactor code for qnx nto targets to share more code in file `nto_qnx.rs` 1. Add support for an additional network stack on nto qnx 7.1. QNX 7.1 supports two network stacks: 1. `io-pkt`, which is default 2. `io-sock`, which is optional on 7.1 but default in QNX 8.0 As one can see in the [io-sock migration notes](https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.io_sock/topic/migrate_app.html), this changes the libc API in a way similar to e.g. linux-gnu vs. linux-musl. This change adds a new target which has a different value for `target_env`, so that e.g. libc can distinguish between both APIs. 2. Add initial support for QNX 8.0, thanks to AkhilTThomas. As it turned out, the problem with forking many processes still exists in QNX 8.0. Because if this, we are now using it for any QNX version (i.e. not check for `target_env` anymore).
2025-01-26Windows: Test that deleting a running binary failsChris Denton-2/+4
2025-01-26Update platform information for remove_fileChris Denton-2/+2
2025-01-26Windows: remove readonly filesChris Denton-3/+23
2025-01-25Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-SimulacrumJacob Pratt-10/+5
Update emscripten std tests This disables a bunch of emscripten tests that test things emscripten doesn't support and re-enables a whole bunch of tests which now work just fine on emscripten. Tested with `EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" ./x.py test library/ --target wasm32-unknown-emscripten`.
2025-01-25Improve and expand documentation of pipesJosh Triplett-8/+14
- Simplify some of the language - Minor grammar fixes - Don't imply that pipes *only* work across multiple processes; instead, *suggest* that they're typically used across two or more separate processes. - Specify that portable applications cannot use multiple readers or multiple writers for messages larger than a byte, due to potential interleaving. - Remove no-longer-referenced footnote URLs.
2025-01-25Correct comment for FreeBSD and DragonFly BSD in unix/threadHuang Qi-1/+1
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-25Rollup merge of #135991 - no1wudi:master, r=thomccMatthias Krüger-3/+8
Fix set_name in thread mod for NuttX Replace `pthread_set_name_np` with `pthread_setname_np` for NuttX in the `set_name` function, this change aligns the implementation with the correct API available on NuttX This patch ensures thread naming works correctly on NuttX platforms. See also: https://github.com/rust-lang/libc/blob/0f9f8c91adb0365c0d13b34ec27ac8019818cf1f/src/unix/nuttx/mod.rs#L562 https://github.com/apache/nuttx/blob/8f3a2a6f7645dd95b6a7608b9cde3cb693b118c2/include/pthread.h#L511-L514
2025-01-24Rollup merge of #135415 - Harshit933:hard-link-error, r=ChrisDentonMatthias Krüger-0/+1
Add `File already exists` error doc to `hard_link` function ## Description If the link path already exists, the error `AlreadyExists` is returned. This commit adds this error to the docs. I tested it with the current rust master version, this error was returned when there is already a link for the file is present. This was the error returned: ``` [harshit:../Desktop/rust_compiler_testing/hard_link (master|…5)] cargo +stage1 run Compiling hard_link v0.1.0 (/home/harshit/Desktop/rust_compiler_testing/hard_link) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s Running `target/debug/hard_link` Err(Os { code: 17, kind: AlreadyExists, message: "File exists" }) ``` This is my first PR on rust, any suggestions on which issue I can take next are most welcome :smile: Fixes #130117
2025-01-24Add `File already exists` error doc to `hard_link` functionHarshit Verma-0/+1
If the link path already exists, the error `AlreadyExists` is returned. This commit adds this error to the docs.
2025-01-24Fix set_name in thread mod for NuttXHuang Qi-3/+8
Replace `pthread_set_name_np` with `pthread_setname_np` for NuttX in the `set_name` function, this change aligns the implementation with the correct API available on NuttX This patch ensures thread naming works correctly on NuttX platforms. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-01-24add nto80 x86-64 and aarch64 targetAkhilTThomas-11/+3
Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24Add new target for supporting Neutrino QNX 6.1 with `io-socket` network ↵Florian Bartels-3/+4
stack on aarch64 Signed-off-by: Florian Bartels <Florian.Bartels@elektrobit.com>
2025-01-24Update a bunch of comments from before wasi support was addedbjorn3-5/+4
2025-01-24Remove a bunch of emscripten test ignoresbjorn3-5/+0
They are either outdated as emscripten now supports i128 or they are subsumed by #[cfg_attr(not(panic = "unwind"), ignore]
2025-01-24Fix testing of the standard library with Emscriptenbjorn3-0/+1
This does need EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" avoid several OOMs.
2025-01-23Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushiMatthias Krüger-0/+8
Implement `ByteStr` and `ByteString` types Approved ACP: https://github.com/rust-lang/libs-team/issues/502 Tracking issue: https://github.com/rust-lang/rust/issues/134915 These types represent human-readable strings that are conventionally, but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using escape sequences, and the `Display` impl uses the Unicode replacement character. This is a minimal implementation of these types and associated trait impls. It does not add any helper methods to other types such as `[u8]` or `Vec<u8>`. I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`, when those would be the second implementation for a type (counting the `T` impl), to avoid potential inference failures. We can attempt to add more impls later in standalone commits, and run them through crater. In addition to the `bstr` feature, I've added a `bstr_internals` feature for APIs provided by `core` for use by `alloc` but not currently intended for stabilization. This API and its implementation are based *heavily* on the `bstr` crate by Andrew Gallant (`@BurntSushi).` r? `@BurntSushi`
2025-01-22Rollup merge of #135856 - fmease:library-mv-obj-save-dyn-compat-ii, r=tgross35Matthias Krüger-5/+4
Library: Finalize dyn compatibility renaming Update the Reference link to use the new URL fragment from https://github.com/rust-lang/reference/pull/1666 (this change has finally hit stable). Fixes a FIXME. Follow-up to #130827. Part of #130852.
2025-01-22Rollup merge of #135837 - ChrisDenton:trunc, r=NoratriebMatthias Krüger-3/+0
Remove test panic from File::open Fixes #135831
2025-01-22Library: Finalize dyn compatibility renamingLeón Orell Valerian Liehr-5/+4
2025-01-21Remove test panic from File::openChris Denton-3/+0
2025-01-21fix OsString::from_encoded_bytes_unchecked descriptionMarijn Schouten-2/+2
2025-01-21Auto merge of #135224 - wyfo:tls-panic-outline, r=cuviperbors-8/+16
Outline panicking code for `LocalKey::with` See https://github.com/rust-lang/rust/pull/115491 for prior related modifications. https://godbolt.org/z/MTsz87jGj shows a reduction of the code size for TLS accesses.
2025-01-20Rollup merge of #135626 - clubby789:env-note, r=ibraheemdev许杰友 Jieyou Xu (Joe)-0/+8
doc: Point to methods on `Command` as alternatives to `set/remove_var` Make these methods more discoverable, as configuring a child process is a common reason for manipulating the environment.
2025-01-20Rollup merge of #135491 - ↵许杰友 Jieyou Xu (Joe)-34/+4
RalfJung:remove-dead-rustc_allowed_through_unstable_modules, r=Mark-Simulacrum Remove dead rustc_allowed_through_unstable_modules for std::os::fd contents As far as I was able to reconstruct, the history here is roughly as follows: - https://github.com/rust-lang/rust/pull/99723 added some `rustc_allowed_through_unstable_modules` to the types in `std::os::fd::raw` since they were accessible on stable via the unstable `std::os::wasi::io::AsRawFd` path. (This was needed to fix https://github.com/rust-lang/rust/issues/99502.) - Shortly thereafter, https://github.com/rust-lang/rust/pull/98368 re-organized things so that instead of re-exporting from an internal `std::os::wasi::io::raw`, `std::os::wasi::io::AsRawFd` is now directly re-exported from `std::os::fd`. This also made `library/std/src/os/wasi/io/raw.rs` entirely dead code as far as I can tell, it's not imported by anything any more. - Shortly thereafter, https://github.com/rust-lang/rust/pull/103308 stabilizes `std::os::wasi::io`, so `rustc_allowed_through_unstable_modules` is not needed any more to access `std::os::wasi::io::AsRawFd`. There is even a comment in `library/std/src/os/wasi/io/raw.rs` saying the attribute can be removed now, but that file is dead code so it is not touched as part of the stabilization. I did a grep for `pub use crate::os::fd` and all the re-exports I could find are in stable modules. So given all that, we can remove the `rustc_allowed_through_unstable_modules` (hoping they are not also re-exported somewhere else, it's really hard to be sure about this). I have checked that std still builds after this PR on the wasm32-wasip2 target.
2025-01-20Rollup merge of #135446 - klensy:panic_immediate_abort_ext, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-0/+5
further improve panic_immediate_abort by removing rtprintpanic! messages Reduces binary size using `panic_immediate_abort` by removing strings used by `rtprintpanic!`. for `main.rs` ```rust fn main() { println!("Hello, world!"); } ``` with `Cargo.toml` ```toml [package] name = "tst" version = "0.1.0" edition = "2024" [dependencies] [profile.release] lto = true codegen-units = 1 panic = "abort" ``` and build with `RUSTFLAGS="-Zlocation-detail=none -Zfmt-debug=none" cargo +stage-1 b -r -Z build-std=std,panic_abort -Z build-std-features=optimize_for_size,panic_immediate_abort` for `x86_64-unknown-linux-gnu` This reduces size: | before | after | type | | - | - | - | | 25256 | 21880 | unstripped | | 18072 | 15288 | stripped |
2025-01-18Rollup merge of #135661 - tgross35:stabilize-float_next_up_down, r=scottmcmMatthias Krüger-1/+0
Stabilize `float_next_up_down` FCP completed at [1]. For `f16` and `f128`, this just removes the gates in comments and doctests. Closes https://github.com/rust-lang/rust/issues/91399 [1]: https://github.com/rust-lang/rust/issues/91399#issuecomment-2598734570
2025-01-18Rollup merge of #135583 - NobodyXu:move-pipe-to-io, r=joshtriplettMatthias Krüger-288/+272
Move `std::pipe::*` into `std::io` Resolve concern from final comment period https://github.com/rust-lang/rust/issues/127154#issuecomment-2590419895
2025-01-17Stabilize `float_next_up_down`Trevor Gross-1/+0
FCP completed at [1]. Closes https://github.com/rust-lang/rust/issues/91399 [1]: https://github.com/rust-lang/rust/issues/91399#issuecomment-2598734570
2025-01-18Fix import of pipe in kernel_copy.rsJiahao XU-3/+2
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-17doc: Point to methods on `Command` as alternatives to `set/remove_var`clubby789-0/+8
2025-01-16Rollup merge of #135556 - AeonSolstice:patch-1, r=tgross35Matthias Krüger-1/+1
Clarify note in `std::sync::LazyLock` example I doubt most people know what it means, as I did not until a week ago. In the current form, it seems like a `TODO:`.
2025-01-17Move `std::pipe::*` into `std::io`Jiahao XU-285/+270
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>