about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-11-22Rollup merge of #133313 - thesummer:fix-arc4random, r=cuviper许杰友 Jieyou Xu (Joe)-2/+0
Use arc4random of libc for RTEMS target Switch to the `arc4random` from libc. It is available since libc 0.2.162
2024-11-22Rollup merge of #133238 - heiher:loong-stdarch-rexport, r=Amanieu许杰友 Jieyou Xu (Joe)-0/+2
re-export `is_loongarch_feature_detected` r? ``@Amanieu``
2024-11-22Fix typo in `std::thread::Scope::spawn` documentation.Colin Finck-1/+1
2024-11-22library: update comment around close()Ralf Jung-10/+11
2024-11-22Don't try to use confstr in MiriMads Marquart-4/+6
2024-11-21Use arc4random of libc for RTEMS targetJan Sommer-2/+0
Is available since libc 0.2.162
2024-11-21Mention that std::fs::remove_dir_all fails on filesPanagiotis "Ivory" Vasilopoulos-1/+2
This is explicitly mentioned for std::fs::remove_file's documentation, but not in the aforementioned function. It is more likely for a slightly lazy programmer to believe that removing a file would work and that they do not have to distinguish between directories (with contents) and files themself, because of the function's recursive nature and how it distinguishes between files and directories when removing them.
2024-11-20implement OsString::truncatebinarycat-4/+8
2024-11-20Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplettMatthias Krüger-2/+4
Mark `get_mut` and `set_position` in `std::io::Cursor` as const. Relevant tracking issue: #130801 The methods `get_mut` and `set_position` can trivially be marked as const due to #57349 being stabilised.
2024-11-20Rollup merge of #129838 - Ayush1325:uefi-process-args, r=joboetMatthias Krüger-12/+56
uefi: process: Add args support - Wrap all args with quotes. - Escape ^ and " inside quotes using ^. - Doing reverse of arg parsing: https://github.com/rust-lang/rust/blob/d571ae851d93541bef826c3c48c1e9ad99da77d6/library/std/src/sys/pal/uefi/args.rs#L81 r​? joboet
2024-11-20re-export `is_loongarch_feature_detected`WANG Rui-0/+2
2024-11-19UniqueRc: platform-specific AsFd/Handle/etc impls to mirror RcZachary S-0/+33
2024-11-19Rollup merge of #133183 - n0toose:improve-remove-dir-docs, r=joboetMatthias Krüger-0/+4
Mention std::fs::remove_dir_all in std::fs::remove_dir
2024-11-19Rollup merge of #125405 - m-ou-se:thread-add-spawn-hook, r=WaffleLapkinMatthias Krüger-7/+175
Add std::thread::add_spawn_hook. Implementation of https://github.com/rust-lang/rfcs/pull/3642
2024-11-19Update doc comments for spawn hook.Mara Bos-2/+6
2024-11-19Address review comments.Mara Bos-7/+6
Co-authored-by: waffle <waffle.lapkin@gmail.com>
2024-11-19Fix tracking issue.Mara Bos-1/+1
2024-11-19Add tracking issue.Mara Bos-2/+2
2024-11-19Use Send + Sync for spawn hooks.Mara Bos-2/+2
2024-11-19Add thread Builder::no_hooks().Mara Bos-7/+24
2024-11-19Update thread spawn hooks.Mara Bos-35/+84
1. Make the effect thread local. 2. Don't return a io::Result from hooks.
2024-11-19Use add_spawn_hook for libtest's output capturing.Mara Bos-4/+0
2024-11-19Add std::thread::add_spawn_hook.Mara Bos-0/+103
2024-11-19Auto merge of #133205 - matthiaskrgr:rollup-xhhhp5u, r=matthiaskrgrbors-0/+3
Rollup of 4 pull requests Successful merges: - #131081 (Use `ConstArgKind::Path` for all single-segment paths, not just params under `min_generic_const_args`) - #132577 (Report the `unexpected_cfgs` lint in external macros) - #133023 (Merge `-Zhir-stats` into `-Zinput-stats`) - #133200 (ignore an occasionally-failing test in Miri) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-19ignore an occasionally-failing test in MiriRalf Jung-0/+3
2024-11-19Rollup merge of #132758 - nnethercote:improve-get_key_value-docs, r=cuviperLeón Orell Valerian Liehr-4/+36
Improve `{BTreeMap,HashMap}::get_key_value` docs. They are unusual methods. The docs don't really describe the cases when they might be useful (as opposed to just `get`), and the examples don't demonstrate the interesting cases at all. This commit improves the docs and the examples.
2024-11-18Mention std::fs::remove_dir_all in std::fs::remove_dirPanagiotis "Ivory" Vasilopoulos-0/+4
2024-11-18wasi/fs: Improve stopping condition for <ReadDir as Iterator>::nextPiotr Osiewicz-14/+17
When upgrading [Zed](https://github.com/zed-industries/zed/pull/19349) to Rust 1.82 I've encountered a test failure in our test suite. Specifically, one of our extension tests started hanging. I've tracked it down to a call to std::fs::remove_dir_all not returning when an extension is compiled with Rust 1.82 Our extension system uses WASM components, thus I've looked at the diff between 1.81 and 1.82 with respect to WASI and found 736f773844e7ebf05ccb827c17b7ad9eb28aa295 As it turned out, calling remove_dir_all from extension returned io::ErrorKind::NotFound in 1.81; the underlying issue is that the ReadDir iterator never actually terminates iteration, however since it loops around, with 1.81 we'd come across an entry second time and fail to remove it, since it would've been removed previously. With 1.82 and 736f773844e7ebf05ccb827c17b7ad9eb28aa295 it is no longer the case, thus we're seeing the hang. This commit makes ReadDir::next adhere to readdir contract, namely it will no longer call readdir once the returned # of bytes is smaller than the size of a passed-in buffer. Previously we'd only terminate the loop if readdir returned 0.
2024-11-18std: allow after-main use of synchronization primitivesjoboet-26/+59
By creating an unnamed thread handle when the actual one has already been destroyed, synchronization primitives using thread parking can be used even outside the Rust runtime. This also fixes an inefficiency in the queue-based `RwLock`: if `thread::current` was not initialized yet, it will create a new handle on every parking attempt without initializing `thread::current`. The private `current_or_unnamed` function introduced here fixes this.
2024-11-18Auto merge of #133160 - jhpratt:rollup-wzj9q15, r=jhprattbors-0/+6
Rollup of 4 pull requests Successful merges: - #132934 (Overhaul the `-l` option parser (for linking to native libs)) - #133142 (rename rustc_const_stable_intrinsic -> rustc_intrinsic_const_stable_indirect) - #133145 (Document alternatives to `static mut`) - #133158 (Subtree update of `rust-analyzer`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-18Auto merge of #128219 - connortsui20:rwlock-downgrade, r=tgross35bors-261/+662
Rwlock downgrade Tracking Issue: #128203 This PR adds a `downgrade` method for `RwLock` / `RwLockWriteGuard` on all currently supported platforms. Outstanding questions: - [x] ~~Does the `futex.rs` change affect performance at all? It doesn't seem like it will but we can't be certain until we bench it...~~ - [x] ~~Should the SOLID platform implementation [be ported over](https://github.com/rust-lang/rust/pull/128219#discussion_r1693470090) to the `queue.rs` implementation to allow it to support downgrades?~~
2024-11-18Improve `{BTreeMap,HashMap}::get_key_value` docs.Nicholas Nethercote-4/+36
They are unusual methods. The docs don't really describe the cases when they might be useful (as opposed to just `get`), and the examples don't demonstrate the interesting cases at all. This commit improves the docs and the examples.
2024-11-18Document alternatives to `static mut`Kornel-0/+6
2024-11-16Add `DerefMut` for `Lazy[Cell/Lock]` that delegates to the unstable ↵Chayim Refael Friedman-1/+9
`force_mut()`
2024-11-16reduce threads in downgrade testConnor Tsui-1/+1
2024-11-16fix `DOWNGRADED` bit unpreservedConnor Tsui-3/+3
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-11-16fix memory ordering bug + bad testConnor Tsui-48/+33
This commit fixes a memory ordering bug in the futex implementation (`Relaxed` -> `Release` on `downgrade`). This commit also removes a badly written test that deadlocked and replaces it with a more reasonable test based on an already-tested `downgrade` test from the parking-lot crate.
2024-11-16add safety comments for queue implementationConnor Tsui-13/+25
2024-11-16add `downgrade` to `queue` implementationConnor Tsui-70/+206
This commit adds the `downgrade` method onto the inner `RwLock` queue implementation. There are also a few other style patches included in this commit. Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-11-16modify queue implementation documentationConnor Tsui-191/+214
This commit only has documentation changes and a few things moved around the file. The very few code changes are cosmetic: changes like turning a `match` statement into an `if let` statement or reducing indentation for long if statements. This commit also adds several safety comments on top of `unsafe` blocks that might not be immediately obvious to a first-time reader. Code "changes" are in: - `add_backlinks_and_find_tail` - `lock_contended` A majority of the changes are just expanding the comments from 80 columns to 100 columns.
2024-11-16add `downgrade` to `futex` implementationConnor Tsui-5/+47
2024-11-16add simple `downgrade` implementationsConnor Tsui-0/+17
2024-11-16add `downgrade` method onto `RwLockWriteGuard`Connor Tsui-4/+70
2024-11-16add `RwLock` `downgrade` testsConnor Tsui-2/+122
2024-11-14Rollup merge of #132984 - sunshowers:pipe2, r=tgross35Jubilee-0/+1
[illumos] use pipe2 to create anonymous pipes pipe2 allows the newly-created pipe to atomically be CLOEXEC. pipe2 was added to illumos a long time ago: https://github.com/illumos/illumos-gate/commit/5dbfd19ad5fcc2b779f40f80fa05c1bd28fd0b4e. I've verified that this change passes all of std's tests on illumos.
2024-11-14Rollup merge of #132977 - cberner:fix_solaris, r=tgross35Jubilee-0/+108
Fix compilation error on Solaris due to flock usage PR 130999 added the file_lock feature, but libc does not define flock() for the Solaris platform leading to a compilation error. Additionally, I went through all the Tier 2 platforms and read through their documentation to see whether flock was implemented. This turned up 5 more Unix platforms where flock is not supported, even though it may exist in the libc crate. Fixes https://github.com/rust-lang/rust/issues/132921 Related to #130999
2024-11-14Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviperJubilee-6/+95
Add as_slice/into_slice for IoSlice/IoSliceMut. ACP: https://github.com/rust-lang/libs-team/issues/93 Tracking issue: #132818 Based on a623c5233ae7f6b540e5c00f2be02f40b33b0793 (CC `@mpdn)` and #111277 (CC `@Lucretiel).` Closes: #124659 Tracking Issue: TODO try-job: test-various try-job: dist-various-1 try-job: dist-various-2 r? libs
2024-11-14Remove one stray space.Peter Gervai-1/+1
2024-11-14Rollup merge of #133027 - no1wudi:master, r=jhprattGuillaume Gomez-1/+1
Fix a copy-paste issue in the NuttX raw type definition This file is copied from the rtems as initial implementation, and forgot to change the OS name in the comment.
2024-11-14Fix a copy-paste issue in the NuttX raw type definitionHuang Qi-1/+1
This file is copied from the rtems as initial implementation, and forgot to change the OS name in the comment. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>