about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-08-27Rollup merge of #145335 - clarfonthey:wtf8-core-alloc, r=Mark-SimulacrumMatthias Krüger-1842/+40
Move WTF-8 code from std into core and alloc This is basically a small portion of rust-lang/rust#129411 with a smaller scope. It *does not*\* affect any public APIs; this code is still internal to the standard library. It just moves the WTF-8 code into `core` and `alloc` so it can be accessed by `no_std` crates like `backtrace`. > \* The only public API this affects is by adding a `Debug` implementation to `std::os::windows::ffi::EncodeWide`, which was not present before. This is due to the fact that `core` requires `Debug` implementations for all types, but `std` does not (yet) require this. Even though this was ultimately changed to be a wrapper over the original type, not a re-export, I decided to keep the `Debug` implementation so it remains useful. Like we do with ordinary strings, the tests are still located entirely in `alloc`, rather than splitting them into `core` and `alloc`. ---- Reviewer note: for ease of review, this is split into three commits: 1. Moving the original files into their new "locations" 2. Actually modifying the code to compile. 3. Removing aesthetic changes that were made so that the diff for commit 2 was readable. You can review commits 1 and 3 to verify these claims, but commit 2 contains the majority of the changes you should care about. ---- API changes: `impl Debug for std::os::windows::ffi::EncodeWide`
2025-08-27Rollup merge of #145290 - ntc2:patch-1, r=joshtriplett,tgross35Matthias Krüger-0/+3
Improve std::fs::read_dir docs Call out early that the results returned can differ across calls / aren't deterministic. This was already mentioned at the bottom of examples, but I think it's worth calling out early, since this caused at least one person (me!) great confusion.
2025-08-27Rollup merge of #145078 - minxuanz:riscv-cacheline, r=samueltardieuMatthias Krüger-5/+3
Fix wrong cache line size of riscv64 see https://go-review.googlesource.com/c/go/+/526659, All of riscv CPU using 64B for cache-line size.
2025-08-27Improve std::fs::read_dir docsNathan Collins-0/+3
Call out early that the results returned can differ across calls / aren't deterministic. This was already mentioned at the bottom of examples, but I think it's worth calling out early, since this caused at least one person (me!) great confusion. [ Added a comma to the docs, reflowed commit message - Trevor ]
2025-08-26Rollup merge of #145615 - lorenzleutgeb:socket-doc, r=ChrisDentonGuillaume Gomez-1/+1
Fix doc of `std::os::windows::io::BorrowedSocket::borrow_raw` A small oversight in 0cb69dec57f I noticed while reading.
2025-08-26Rollup merge of #144373 - hkBst:remove-deprecated-1, r=jhprattGuillaume Gomez-191/+28
remove deprecated Error::description in impls [libs-api permission](https://github.com/rust-lang/libs-team/issues/615#issuecomment-3074045829) r? `@cuviper` or `@jhpratt`
2025-08-26remove deprecated Error::description in implsMarijn Schouten-191/+28
2025-08-25fix(std): Add __my_thread_exit stub for QNX 8Rafael RL-1/+1
This commit adds an empty stub for the function for QNX 8 targets. This symbol is required by the unwinder but is not present, causing a linking failure when building with the standard library. Address review feedback: use whitelist for QNX versions
2025-08-23Rollup merge of #145799 - ada4a:patch-3, r=GuillaumeGomezJacob Pratt-1/+1
std/src/lib.rs: mention "search button" instead of "search bar" r? ```@GuillaumeGomez```
2025-08-23Rollup merge of #145307 - connortsui20:lazylock-poison-msg, r=AmanieuJacob Pratt-3/+6
Fix `LazyLock` poison panic message Fixes the issue raised in https://github.com/rust-lang/rust/pull/144872#issuecomment-3151100248 r? ```@Amanieu```
2025-08-23std/src/lib.rs: mention "search button" instead of "search bar"Ada Alakbarova-1/+1
2025-08-23Rollup merge of #144452 - morinmorin:apple/update_read_limit, r=ChrisDentonSamuel Tardieu-3/+3
std/sys/fd: Relax `READ_LIMIT` on Darwin Darwin's `read`/`write` syscalls emit `EINVAL` only when `nbyte > INT_MAX`. The case `nbyte == INT_MAX` is valid, so the subtraction (`- 1`) in ```rust const READ_LIMIT: usize = if cfg!(target_vendor = "apple") { libc::c_int::MAX as usize - 1 // <- HERE } else { libc::ssize_t::MAX as usize }; ``` can be removed. I tested that the case `nbyte == INT_MAX` is valid on various versions of macOS, including old one like Mac OS X 10.5. The man page says: - read() and pread() will fail if the parameter nbyte exceeds INT_MAX (link: https://keith.github.io/xcode-man-pages/read.2.html) - write() and pwrite() will fail if the parameter nbyte exceeds INT_MAX (link: https://keith.github.io/xcode-man-pages/write.2.html) Here are links to Darwin's code: - [macOS 15.5] https://github.com/apple-oss-distributions/xnu/blob/e3723e1f17661b24996789d8afc084c0c3303b26/bsd/kern/sys_generic.c#L307 - [Mac OS X 10.2] https://github.com/apple/darwin-xnu/blob/d738f900846ed2d5f685e18bf85ce63b0176f61a/bsd/kern/sys_generic.c#L220 Related PR: rust-lang/rust#38622.
2025-08-23std library: use execinfo library also on NetBSD.Havard Eidnes-0/+1
2025-08-23fix visibility of private gettersConnor Tsui-3/+6
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23move `WaitTimeoutResult` up to `mod.rs`Connor Tsui-137/+68
Since `WaitTimeoutResult` is poison-agnostic, we want to use the same type for both variants of `Condvar`. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23change `Barrier` implementation to use `nonpoison::Condvar`Connor Tsui-5/+3
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23add `nonpoison::condvar` implementationConnor Tsui-2/+524
Adds the equivalent `nonpoison` types to the `poison::condvar` module. These types and implementations are gated under the `nonpoison_condvar` feature gate. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23Fix STD build failing for target_os = espidfivmarkov-2/+11
2025-08-22Rollup merge of #145633 - qxzcode:patch-1, r=jhprattJacob Pratt-4/+4
Fix some typos in LocalKey documentation A few minor grammatical/wording changes in the `std::thread::LocalKey` documentation.
2025-08-22Rollup merge of #144648 - connortsui20:nonpoison_rwlock, r=Mark-SimulacrumJacob Pratt-327/+1458
Implementation: `#[feature(nonpoison_rwlock)]` Tracking Issue: https://github.com/rust-lang/rust/issues/134645 This PR continues the effort made in https://github.com/rust-lang/rust/pull/144022 by adding the implementation of `nonpoison::rwlock`. Many of the changes here are similar to the changes made to implement `nonpoison::mutex`. The only real difference is that this PR includes a reorganizing of the existing `poison::rwlock` file that hopefully makes both variants more readable. ### Related PRs - `nonpoison_condvar` implementation: https://github.com/rust-lang/rust/pull/144651 - `nonpoison_once` implementation: https://github.com/rust-lang/rust/pull/144653
2025-08-22modify `LazyLock` poison panic messageConnor Tsui-3/+6
Fixes an issue where if the underlying `Once` panics because it is poisoned, the panic displays the wrong message. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-22Stabilize `round_char_boundary` featureokaneco-1/+0
2025-08-21Rollup merge of #137494 - nabijaczleweli:dup, r=Mark-SimulacrumJacob Pratt-24/+26
libstd: init(): dup() subsequent /dev/nulls instead of opening them again This will be faster, and also it deduplicates the code so win/win The dup() is actually infallible here. But whatever. Before: ``` poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 1 ([{fd=2, revents=POLLNVAL}]) openat(AT_FDCWD, "/dev/null", O_RDWR) = 2 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f5749313050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0 poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 2 ([{fd=0, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}]) openat(AT_FDCWD, "/dev/null", O_RDWR) = 0 openat(AT_FDCWD, "/dev/null", O_RDWR) = 2 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7efe12006050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0 poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 3 ([{fd=0, revents=POLLNVAL}, {fd=1, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}]) openat(AT_FDCWD, "/dev/null", O_RDWR) = 0 openat(AT_FDCWD, "/dev/null", O_RDWR) = 1 openat(AT_FDCWD, "/dev/null", O_RDWR) = 2 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fc2dc7ca050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0 ``` After: ``` poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 1 ([{fd=1, revents=POLLNVAL}]) openat(AT_FDCWD, "/dev/null", O_RDWR) = 1 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f488a3fb050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0 poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 2 ([{fd=1, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}]) openat(AT_FDCWD, "/dev/null", O_RDWR) = 1 dup(1) = 2 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f1a8943c050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0 poll([{fd=0, events=0}, {fd=1, events=0}, {fd=2, events=0}], 3, 0) = 3 ([{fd=0, revents=POLLNVAL}, {fd=1, revents=POLLNVAL}, {fd=2, revents=POLLNVAL}]) openat(AT_FDCWD, "/dev/null", O_RDWR) = 0 dup(0) = 1 dup(0) = 2 rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f4e3a4c7050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0 ```
2025-08-21Rollup merge of #145673 - Berrysoft:cygwin-fix-flock, r=joshtriplettJacob Pratt-0/+10
Add flock support for cygwin See discussion: https://github.com/rust-lang/rust/issues/145534#issuecomment-3207265236 cc: ``@jeremyd2019``
2025-08-21Rollup merge of #145525 - typesanitizer:vg/doc, r=Mark-SimulacrumJacob Pratt-1/+1
stdlib: Replace typedef -> type alias in doc comment 'typedef' is jargon from C and C++. Since the Rust reference uses the term [type alias](https://doc.rust-lang.org/reference/items/type-aliases.html), this patch changes the doc comment in io/error.rs to also use 'type alias'.
2025-08-21Rollup merge of #144758 - QnJ1c2kNCg:master, r=NoratriebJacob Pratt-6/+6
[Doc] Add links to the various collections Add a few links to the collections mentioned in the module doc for Collections.
2025-08-20Move WTF-8 code from std to core/allocltdk-8/+40
2025-08-20Copy WTF-8 code into core/alloc (for better diffs)ltdk-1834/+0
2025-08-21Add flock support for cygwin王宇逸-0/+10
2025-08-20Rollup merge of #145006 - ginnyTheCat:docs-skip-until, r=ibraheemdevJacob Pratt-2/+7
Clarify EOF handling for `BufRead::skip_until` This aligns `BufRead::skip_until`'s description more with `BufRead::read_until` in terms of how it handles EOF and extends the doctest to include this behavior.
2025-08-19Auto merge of #145601 - jieyouxu:rollup-t5mbqhc, r=jieyouxubors-1/+1
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145538 (bufreader::Buffer::backshift: don't move the uninit bytes) - rust-lang/rust#145542 (triagebot: Don't warn no-mentions on subtree updates) - rust-lang/rust#145549 (Update rust maintainers in openharmony.md) - rust-lang/rust#145550 (Avoid using `()` in `derive(From)` output.) - rust-lang/rust#145556 (Allow stability attributes on extern crates) - rust-lang/rust#145560 (Remove unused `PartialOrd`/`Ord` from bootstrap) - rust-lang/rust#145568 (ignore frontmatters in `TokenStream::new`) - rust-lang/rust#145571 (remove myself from some adhoc-groups and pings) - rust-lang/rust#145576 (Add change tracker entry for `--timings`) - rust-lang/rust#145578 (Add VEXos "linked files" support to `armv7a-vex-v5`) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-19Tweak wording againQuinn Tucker-1/+1
2025-08-19Adjust wording for concisenessQuinn Tucker-2/+2
2025-08-19Fix typos in LocalKey documentationQuinn Tucker-2/+2
2025-08-19Auto merge of #145600 - jieyouxu:rollup-jw0bpnt, r=jieyouxubors-2/+12
Rollup of 15 pull requests Successful merges: - rust-lang/rust#145338 (actually provide the correct args to coroutine witnesses) - rust-lang/rust#145429 (Couple of codegen_fn_attrs improvements) - rust-lang/rust#145452 (Do not strip binaries in bootstrap everytime if they are unchanged) - rust-lang/rust#145464 (Stabilize `const_pathbuf_osstring_new` feature) - rust-lang/rust#145474 (Properly recover from parenthesized use-bounds (precise capturing lists) plus small cleanups) - rust-lang/rust#145486 (Fix `unicode_data.rs` mention message) - rust-lang/rust#145490 (Trace some basic I/O operations in bootstrap) - rust-lang/rust#145493 (remove `should_render` in `PrintAttribute` derive) - rust-lang/rust#145500 (Port must_use to the new target checking) - rust-lang/rust#145505 (Simplify span caches) - rust-lang/rust#145510 (Visit and print async_fut local for async drop.) - rust-lang/rust#145511 (Rust build fails on OpenBSD after using file_lock feature) - rust-lang/rust#145532 (resolve: debug for block module) - rust-lang/rust#145533 (Reorder `lto` options from most to least optimizing) - rust-lang/rust#145537 (Do not consider a `T: !Sized` candidate to satisfy a `T: !MetaSized` obligation.) r? `@ghost` `@rustbot` modify labels: rollup
2025-08-19Fix doc of `std::os::windows::io::BorrowedSocket::borrow_raw`Lorenz Leutgeb-1/+1
A small oversight in 0cb69dec57f I noticed while reading.
2025-08-19Rollup merge of #145538 - lolbinarycat:std-bufreader-buffer-backshift-less, ↵许杰友 Jieyou Xu (Joe)-1/+1
r=tgross35 bufreader::Buffer::backshift: don't move the uninit bytes previous code was perfectly sound because of MaybeUninit, but it did waste cycles on copying memory that is known to be uninitialized.
2025-08-19Rollup merge of #145511 - semarie:push-rnytptsoxrxn, r=joshtriplett许杰友 Jieyou Xu (Joe)-0/+10
Rust build fails on OpenBSD after using file_lock feature PR 130999 added the file_lock feature, but doesn't included OpenBSD in the supported targets (Tier 3 platform), leading to a compilation error ("try_lock() not supported"). Cc `@cberner` Related to rust-lang/rust#130999
2025-08-19Rollup merge of #145464 - Kivooeo:stabilize-const_pathbuf_osstring_new, ↵许杰友 Jieyou Xu (Joe)-2/+2
r=ibraheemdev Stabilize `const_pathbuf_osstring_new` feature This closes [tracking issue](https://github.com/rust-lang/rust/issues/141520) and stabilises `{OsString, PathBuf}::new` in const
2025-08-19Rollup merge of #145025 - lolbinarycat:ci-tidy-spellcheck, r=Kobzol许杰友 Jieyou Xu (Joe)-5/+5
run spellcheck as a tidy extra check in ci This is probably how it should've been done from the start. r? ``@Kobzol``
2025-08-19Rollup merge of #142938 - lolbinarycat:std-set_permissions_nofollow, ↵许杰友 Jieyou Xu (Joe)-0/+34
r=ibraheemdev implement std::fs::set_permissions_nofollow on unix implementation of https://github.com/rust-lang/rust/issues/141607
2025-08-19Rollup merge of #145563 - Kobzol:remove-from-from-prelude, r=petrochenkovStuart Cook-0/+8
Remove the `From` derive macro from prelude The new `#[derive(From)]` functionality (implemented in https://github.com/rust-lang/rust/pull/144922) caused name resolution ambiguity issues (https://github.com/rust-lang/rust/issues/145524). The reproducer looks e.g. like this: ```rust mod foo { pub use derive_more::From; } use foo::*; #[derive(From)] // ERROR: `From` is ambiguous struct S(u32); ``` It's pretty unfortunate that it works like this, but I guess that there's not much to be done here, and we'll have to wait for the next edition to put the `From` macro into the prelude. That will probably require https://github.com/rust-lang/rust/pull/139493 to land. I created a new module in core (and re-exported it in std) called `from`, where I re-exported the `From` macro. I *think* that since this is a new module, it should not have the same backwards incompatibility issue. Happy to hear suggestions about the naming - maybe it would make sense as `core::macros::from::From`? But we already had a precedent in the `core::assert_matches` module, so I just followed suit. Fixes: https://github.com/rust-lang/rust/issues/145524 r? ``@petrochenkov``
2025-08-19Rollup merge of #140956 - Kixunil:impl-partialeq-str-for-path, r=AmanieuStuart Cook-0/+65
`impl PartialEq<{str,String}> for {Path,PathBuf}` This is a revival of #105877 Comparison of paths and strings is expected to be possible and needed e.g. in tests. This change adds the impls os `PartialEq` between strings and paths, both owned and unsized, in both directions. ACP: https://github.com/rust-lang/libs-team/issues/151
2025-08-18Auto merge of #145489 - joshtriplett:cfg-if-not, r=Amanieubors-501/+695
library: Migrate from `cfg_if` to `cfg_select` Migrate the standard library from using the external `cfg_if` crate to using the now-built-in `cfg_select` macro. This does not yet eliminate the dependency from `library/std/Cargo.toml`, because while the standard library itself no longer uses `cfg_if`, it also incorporates the `backtrace` crate, which does. Migration assisted by the following vim command (after selecting the full `cfg_if!` invocation): ``` '<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e ``` This is imperfect, but substantially accelerated the process. This prompts for confirmation on the `} else {` since that can also appear inside one of the arms. This also requires manual intervention to handle any multi-line conditions.
2025-08-18implement std::fs::set_permissions_nofollow on unixbinarycat-0/+34
2025-08-18Remove the `From` derive macro from preludeJakub Beránek-0/+8
To avoid backwards compatibility problems.
2025-08-17bufreader::Buffer::backshift: don't move the uninit bytesbinarycat-1/+1
previous code was perfectly sound because of MaybeUninit, but it did waste cycles on copying memory that is known to be uninitialized.
2025-08-17stdlib: Replace typedef -> type alias in doc commentVarun Gandhi-1/+1
2025-08-17Rust build fails on OpenBSD after using file_lock featureSebastien Marie-0/+10
PR 130999 added the file_lock feature, but doesn't included OpenBSD in the supported targets (Tier 3 platform), leading to a compilation error ("try_lock() not supported").
2025-08-16std: fix more typosbinarycat-2/+2