about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-08-20Copy WTF-8 code into core/alloc (for better diffs)ltdk-1834/+0
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-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-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-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
2025-08-16tidy now installs typos-cli as-needed via cargobinarycat-1/+1
2025-08-16run spellcheck as a tidy extra check in cibinarycat-2/+2
2025-08-16library: Migrate from `cfg_if` to `cfg_select`Josh Triplett-501/+695
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-16Fix typo in doc for library/std/src/fs.rs#set_permissionsAlan Urmancheev-1/+1
"privalage" -> "privilege"
2025-08-15stabilize const pathbuf osstring newKivooeo-2/+2
2025-08-15Rollup merge of #145412 - tgross35:win-tid, r=ChrisDentonJakub Beránek-3/+3
Windows: Replace `GetThreadId`+`GetCurrentThread` with `GetCurrentThreadId` Reference: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentthreadid
2025-08-15Rollup merge of #144210 - Gelbpunkt:thread-stack-size-musl, r=jhprattJakub Beránek-1/+12
std: thread: Return error if setting thread stack size fails Currently, when setting the thread stack size fails, it would be rounded up to the nearest multiple of the page size and the code asserts that the next call to `pthread_attr_setstacksize` succeeds. This may be true for glibc, but it isn't true for musl, which not only enforces a minimum stack size, but also a maximum stack size of `usize::MAX / 4 - PTHREAD_STACK_MIN` [1], triggering the assert rather than erroring gracefully. There isn't any way to handle this properly other than bailing out and letting the user know it didn't succeed. [1]: https://git.musl-libc.org/cgit/musl/tree/src/thread/pthread_attr_setstacksize.c#n5
2025-08-15Rollup merge of #145331 - theemathas:std-prelude-2024, r=tgross35Stuart Cook-1/+1
Make std use the edition 2024 prelude This seem to have been overlooked in <https://github.com/rust-lang/rust/pull/138162>
2025-08-15Rollup merge of #145322 - LorrensP-2158466:early-prelude-processing, ↵Stuart Cook-3/+4
r=petrochenkov Resolve the prelude import in `build_reduced_graph` This pr tries to resolve the prelude import at the `build_reduced_graph` stage. Part of batched import resolution in rust-lang/rust#145108 (cherry picked commit) and maybe needed for rust-lang/rust#139493. r? petrochenkov
2025-08-14Windows: Replace `GetThreadId`+`GetCurrentThread` with `GetCurrentThreadId`Trevor Gross-3/+3
Reference: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentthreadid
2025-08-14std: thread: Return error if setting thread stack size failsJens Reidel-1/+12
Currently, when setting the thread stack size fails, it would be rounded up to the nearest multiple of the page size and the code asserts that the next call to pthread_attr_setstacksize succeeds. This may be true for glibc, but it isn't true for musl, which not only enforces a minimum stack size, but also a maximum stack size of usize::MAX / 4 - PTHREAD_STACK_MIN [1], triggering the assert rather than erroring gracefully. There isn't any way to handle this properly other than bailing out and letting the user know it didn't succeed. [1]: https://git.musl-libc.org/cgit/musl/tree/src/thread/pthread_attr_setstacksize.c#n5 Signed-off-by: Jens Reidel <adrian@travitia.xyz>
2025-08-14resolve prelude import at `build_reduced_graph` phaseLorrensP-2158466-3/+4
2025-08-14Rollup merge of #145299 - eval-exec:exec-fix-145293, r=tgross35Guillaume Gomez-2/+6
doc test: fix mpsc.rs try_send doc test This Pr want to fix the doctest, to make https://github.com/rust-lang/rust/pull/145293 's CI pass: r? ``@Zalathar`` https://github.com/rust-lang/rust/actions/runs/16903356990/job/47887354221 ```bash 2025-08-12T10:19:32.3873237Z test library/std/src/thread/scoped.rs - thread::scoped::ScopedJoinHandle<'scope,T>::join (line 302) ... ok 2025-08-12T10:19:32.4370250Z test library/std/src/time.rs - time::SystemTimeError::duration (line 688) ... ok 2025-08-12T10:19:32.5121966Z test library/std/src/time.rs - time::UNIX_EPOCH (line 664) ... ok 2025-08-12T10:19:32.5122586Z 2025-08-12T10:19:32.5122738Z failures: 2025-08-12T10:19:32.5122973Z 2025-08-12T10:19:32.5123482Z ---- library/std/src/sync/mpsc.rs - sync::mpsc::SyncSender<T>::try_send (line 691) stdout ---- 2025-08-12T10:19:32.5124286Z Test executable failed (exit status: 1). 2025-08-12T10:19:32.5124518Z 2025-08-12T10:19:32.5124605Z stdout: 2025-08-12T10:19:32.5124810Z message 3 received 2025-08-12T10:19:32.5125043Z message 1 received 2025-08-12T10:19:32.5125288Z the third message was never sent 2025-08-12T10:19:32.5125497Z 2025-08-12T10:19:32.5125581Z stderr: 2025-08-12T10:19:32.5125701Z 2025-08-12T10:19:32.5125935Z thread '<unnamed>' (203874) panicked at library/std/src/sync/mpsc.rs:14:25: 2025-08-12T10:19:32.5126459Z called `Result::unwrap()` on an `Err` value: SendError { .. } 2025-08-12T10:19:32.5126836Z stack backtrace: 2025-08-12T10:19:32.5127568Z ␛[0m␛[1m␛[38;5;9merror␛[0m␛[0m␛[1m: the main thread terminated without waiting for all remaining threads␛[0m 2025-08-12T10:19:32.5127971Z 2025-08-12T10:19:32.5128335Z ␛[0m␛[1m␛[38;5;10mnote␛[0m␛[0m␛[1m: set `MIRIFLAGS=-Zmiri-ignore-leaks` to disable this check␛[0m 2025-08-12T10:19:32.5128694Z 2025-08-12T10:19:32.5128943Z ␛[0m␛[1m␛[38;5;9merror␛[0m␛[0m␛[1m: aborting due to 1 previous error␛[0m 2025-08-12T10:19:32.5129519Z 2025-08-12T10:19:32.5129527Z 2025-08-12T10:19:32.5129532Z 2025-08-12T10:19:32.5129537Z 2025-08-12T10:19:32.5129631Z failures: 2025-08-12T10:19:32.5130018Z library/std/src/sync/mpsc.rs - sync::mpsc::SyncSender<T>::try_send (line 691) 2025-08-12T10:19:32.5130396Z 2025-08-12T10:19:32.5130713Z test result: FAILED. 999 passed; 1 failed; 16 ignored; 0 measured; 344 filtered out; finished in 105.92s ```
2025-08-14Rollup merge of #145179 - joshtriplett:number, r=RalfJungGuillaume Gomez-7/+6
Avoid abbreviating "numerator" as "numer", to allow catching typo "numer" elsewhere `typos.toml` has an exception for "numer", to avoid flagging its use as an abbreviation for "numerator". Remove the use of that abbrevation, spelling out "numerator" instead, and remove the exception, so that typo checks can find future instances of "numer" as a typo for "number".
2025-08-13doc test: fix mpsc.rs try_send doc testEval EXEC-2/+6
Signed-off-by: Eval EXEC <execvy@gmail.com>
2025-08-13Rollup merge of #145325 - clarfonthey:cast-init, r=scottmcmJakub Beránek-1/+2
Add `cast_init` and `cast_uninit` methods for pointers ACP: rust-lang/libs-team#627 Tracking issue: rust-lang/rust#145036 This includes an incredibly low-effort search to find uses that could be switched to using these methods. I only searched for `cast::<\w>` and `cast::<MaybeUninit` because there would otherwise be way too much to look through, and I also didn't modify anything inside submodules/subtrees.
2025-08-13Rollup merge of #145303 - m-ou-se:payload-as-str-doc, r=jhprattJakub Beránek-0/+2
Docs: Link to payload_as_str() from payload().
2025-08-13Rollup merge of #144870 - Kivooeo:file_prefix-stabilize, r=tgross35Jakub Beránek-2/+1
Stabilize `path_file_prefix` feature This stabilises `Path::file_prefix`, following the FCP in [tracking issue ](https://github.com/rust-lang/rust/issues/86319) (FCP ended almost a year ago, so if it's needed for proccess we could rerun it) Closes: https://github.com/rust-lang/rust/issues/86319
2025-08-13Make std use the edition 2024 preludeTim (Theemathas) Chirananthavat-1/+1
This seem to have been overlooked in <https://github.com/rust-lang/rust/pull/138162>
2025-08-12Add cast_init and cast_uninit methods for pointersltdk-1/+2
2025-08-12Constify SystemTime methodsltdk-68/+166
2025-08-12Link to payload_as_str() from payload().Mara Bos-0/+2
2025-08-11std: sys: pal: uefi: tests: Add systemtime testsAyush Singh-24/+96
Add tests to ensure that extream system times are still representable. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-08-11std: sys: pal: uefi: Overhaul TimeAyush Singh-18/+110
Use a time representation with 1900-01-01-00:00:00 at timezone -1440 min as anchor. This is the earliest time supported in UEFI. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-08-11Rollup merge of #144350 - Ayush1325:uefi-io, r=tgross35,nicholasbishopStuart Cook-0/+196
std: sys: io: io_slice: Add UEFI types UEFI networking APIs do support vectored read/write. While the types for UDP4, UDP6, TCP4 and TCP6 are defined separately, they are essentially the same C struct. So we can map IoSlice and IoSliceMut to have the same binary representation. Since all UEFI networking types for read/write are DSTs, `IoSlice` and `IoSliceMut` will need to be copied to the end of the transmit/receive structures. So having the same binary representation just allows us to do a single memcpy instead of having to loop and set the DST. cc ``@nicholasbishop``
2025-08-10Rollup merge of #145150 - ChrisDenton:inherit, r=Mark-SimulacrumJacob Pratt-12/+11
Replace unsafe `security_attributes` function with safe `inherit_handle` alternative The `security_attributes` function is marked as safe despite taking a raw pointer which will later be used. Fortunately this function is only used internally and only in one place that has been basically the same for a decade now. However, we only ever set one bool so it's easy enough to replace with something that's actually safe. In the future we might want to expose the ability for users to set security attributes. But that should be properly designed (and safe!).
2025-08-09Avoid abbreviating "numerator" as "numer", to allow catching typo "numer" ↵Josh Triplett-7/+6
elsewhere `typos.toml` has an exception for "numer", to avoid flagging its use as an abbreviation for "numerator". Remove the use of that abbrevation, spelling out "numerator" instead, and remove the exception, so that typo checks can find future instances of "numer" as a typo for "number".
2025-08-09`HashMap`: also add "Usage with custom key types" headingAda Alakbarova-0/+2
2025-08-09`{BTree,Hash}Map`: add "`Entry` API" section headingAda Alakbarova-0/+2
2025-08-09Replace unsafe function with safe alternativeChris Denton-12/+11
The `security_attributes` function is marked as safe despite taking a raw pointer which will later be used. Fortunately this function is only used internally and only in one place that has been basically the same for a decade now. However, we only ever set one bool so it's easy enough to replace with something that's actually safe.
2025-08-09Rollup merge of #145096 - Spxg:w/wasm_atomic, r=tgross35Stuart Cook-0/+4
Fix wasm target build with atomics feature Introduced by https://github.com/rust-lang/rust/pull/115746 close https://github.com/rust-lang/rust/issues/145101
2025-08-08Revert "Rollup merge of #143906 - ↵Jakub Beránek-25/+25
LorrensP-2158466:miri-float-nondet-foreign-items, r=RalfJung" This reverts commit 71f04692c32e181ab566c01942f1418dec8662d4, reversing changes made to 995ca3e532b48b689567533e6b736675e38b741e.
2025-08-08Fix wasm target build with atomics featureSpxg-0/+4