about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2025-07-15Add LocalKey<Cell>::updateCameron Steffen-0/+23
2025-07-15make `std_detect` public dependency of `std`David Mládek-1/+1
2025-07-15Rollup merge of #143910 - ChrisDenton:no-symbolization, r=tgross35Samuel Tardieu-47/+56
Add experimental `backtrace-trace-only` std feature This experimentally allows building std with backtrace but without symbolisation. It does not affect stable and requires build-std to use. This doesn't change the backtrace crate itself so relies on the optimizer to remove the unused parts. Example usage: ```toml # .cargo/config.toml [unstable] build-std = ["core", "alloc", "panic_unwind", "std"] build-std-features = ["backtrace", "backtrace-trace-only", "panic-unwind"] ``` ```toml # Cargo.toml [profile.release] opt-level = 3 lto = "thin" codegen-units = 1 ``` Ideally we should split the backtrace feature into `backtrace-trace` and `backtrace-symbolize` (with the latter dependent on the former) because Cargo features tend to work better when they're positive rather than negative. But I'm keen for this experiment not to break existing users. cc ``@joshtriplett``
2025-07-14Rollup merge of #143710 - joshtriplett:random-updates, r=joshtriplettSamuel Tardieu-19/+9
Updates to random number generation APIs Updates based on discussions about random number generation. - Add comment on `RandomSource::fill_bytes` about multiple calls, to allow efficient implementations for random sources that generate a word at a time. - Drop the `Random` trait in favor of `Distribution<T>`, which will let people make calls like random(1..=6), and which allows for future expansion to non-uniform distributions, as well as floating-point. (For now, this is only implemented for `RangeFull`, to get the interface in place. Subsequent PRs will implement it for other range types.)
2025-07-14Rollup merge of #141809 - ChrisDenton:no-cleaup, r=jhprattSamuel Tardieu-15/+21
Don't call WSACleanup on process exit This isn't necessary as cleanup will happen when the process exits regardless. fixes rust-lang/rust#141799
2025-07-14Don't call WSACleanup on process exitChris Denton-15/+21
2025-07-14Add experimental backtrace-trace-only std featureChris Denton-47/+56
2025-07-14Rollup merge of #143881 - orlp:once-state-repr, r=tgross35Jakub Beránek-9/+12
Use zero for initialized Once state By re-labeling which integer represents which internal state for `Once` we can ensure that the initialized state is the all-zero state. This is beneficial because some CPU architectures (such as Arm) have specialized instructions to specifically branch on non-zero, and checking for the initialized state is by far the most important operation. As an example, take this: ```rust use std::sync::atomic::{AtomicU32, Ordering}; const INIT: u32 = 3; #[inline(never)] #[cold] pub fn slow(state: &AtomicU32) { state.store(INIT, Ordering::Release); } pub fn ensure_init(state: &AtomicU32) { if state.load(Ordering::Acquire) != INIT { slow(state) } } ``` If `INIT` is 3 (as is currently the state for `Once`), we see the following assembly on `aarch64-apple-darwin`: ```asm example::ensure_init::h332061368366e313: ldapr w8, [x0] cmp w8, #3 b.ne LBB1_2 ret LBB1_2: b example::slow::ha042bd6a4f33724e ``` By changing the `INIT` state to zero we get the following: ```asm example::ensure_init::h332061368366e313: ldapr w8, [x0] cbnz w8, LBB1_2 ret LBB1_2: b example::slow::ha042bd6a4f33724e ``` So this PR saves 1 instruction every time a `LazyLock` gets accessed on platforms such as these.
2025-07-13Add comment why we use zero for COMPLETEOrson Peters-1/+4
2025-07-13Use zero for initialized Once stateOrson Peters-8/+8
2025-07-13Attempt to fix up SGX for random API updatesJosh Triplett-2/+2
2025-07-13Rollup merge of #143776 - no1wudi:fix, r=tgross35León Orell Valerian Liehr-1/+1
std: move NuttX to use arc4random for random number generation arc4random support in libc merged in https://github.com/rust-lang/libc/pull/4464, so: * Move `target_os = "nuttx"` from unix_legacy to arc4random section * This aligns NuttX with other POSIX-compliant systems that support arc4random * Improves random number generation quality on NuttX by using the system's built-in arc4random implementation instead of legacy fallback methods NuttX supports arc4random_buf which provides better entropy and security compared to the legacy random number generation methods.
2025-07-13TidyOrson Peters-1/+1
2025-07-13Guarantee 8 bytes of alignment in Thread::into_rawOrson Peters-1/+7
2025-07-12Auto merge of #143810 - matthiaskrgr:rollup-iw7a23z, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - rust-lang/rust#143403 (Port several trait/coherence-related attributes the new attribute system) - rust-lang/rust#143633 (fix: correct assertion to check for 'noinline' attribute presence before removal) - rust-lang/rust#143647 (Clarify and expand documentation for std::sys_common dependency structure) - rust-lang/rust#143716 (compiler: doc/comment some codegen-for-functions interfaces) - rust-lang/rust#143747 (Add target maintainer information for aarch64-unknown-linux-musl) - rust-lang/rust#143759 (Fix typos in function names in the `target_feature` test) - rust-lang/rust#143767 (Bump `src/tools/x` to Edition 2024 and some cleanups) - rust-lang/rust#143769 (Remove support for SwitchInt edge effects in backward dataflow) - rust-lang/rust#143770 (build-helper: clippy fixes) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-11Rollup merge of #143647 - ColtenOuO:master, r=ChrisDentonMatthias Krüger-1/+1
Clarify and expand documentation for std::sys_common dependency structure This PR makes a minor improvement to the module-level documentation of std::sys_common: Replaces the lowercase “dag” with the more standard and explicit form “DAG (Directed Acyclic Graph)” for clarity.
2025-07-11random: Provide a `Distribution<T>` traitJosh Triplett-17/+7
This will let people make calls like random(1..=6), and allows for future expansion to non-uniform distributions, as well as floating-point. For now, this is only implemented for `RangeFull`, to get the interface in place. Subsequent commits will implement it for other range types.
2025-07-11std: move NuttX to use arc4random for random number generationHuang Qi-1/+1
* Move `target_os = "nuttx"` from unix_legacy to arc4random section * This aligns NuttX with other POSIX-compliant systems that support arc4random * Improves random number generation quality on NuttX by using the system's built-in arc4random implementation instead of legacy fallback methods NuttX supports arc4random_buf which provides better entropy and security compared to the legacy random number generation methods. Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-07-11Rollup merge of #143568 - Ayush1325:uefi-tcp4-timeout, r=tgross35Matthias Krüger-25/+97
std: sys: net: uefi: tcp4: Add timeout support - Implement timeout support for read, write and connect. - A software implementation using Instant.
2025-07-11Rollup merge of #142391 - LevitatingBusinessMan:setsid, r=workingjubileeMatthias Krüger-0/+89
rust: library: Add `setsid` method to `CommandExt` trait Add a setsid method to the CommandExt trait so that callers can create a process in a new session and process group whilst still using the POSIX spawn fast path. Tracking issue: rust-lang/rust#105376 ACP: https://github.com/rust-lang/libs-team/issues/184 This PR was previously submitted by ``@HarveyHunt`` (whom I marked as Co-Author in the commit message) in rust-lang/rust#105377. However that PR went stale. I applied the [suggestion](https://github.com/rust-lang/rust/pull/105377/files/231d19fcbfe155b2e85116865adae4253380ff1f#r1893457943) to change the function signature to `fn setsid(&mut self, setsid: bool) -> &mut Command`.
2025-07-11docs: clarify “dag” in std::sys_common doc commentColten-1/+1
2025-07-10Rollup merge of #143668 - biabbas:vxworks, r=NoratriebMatthias Krüger-2/+1
Fix VxWorks build errors fixes rust-lang/rust#143442 r? ``@Noratrieb``
2025-07-10rust: library: Add setsid method to CommandExt traitLevitatingBusinessMan (Rein Fernhout)-0/+89
Add a setsid method to the CommandExt trait so that callers can create a process in a new session and process group whilst still using the POSIX spawn fast path. Co-Authored-By: Harvey Hunt <harveyhunt@fb.com>
2025-07-09std: sys: net: uefi: tcp4: Add timeout supportAyush Singh-25/+97
- Implement timeout support for read, write and connect. - A software implementation using Instant. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-09Add opaque TypeId handles for CTFEOli Scherer-2/+0
2025-07-09core: Remove `BorrowedCursor::init_ref` methodBenoît du Garreau-3/+3
This method was not really useful: at no point one would only need to read the initialized part of the cursor without mutating it.
2025-07-09Fix VxWorks build errorsB I Mohammed Abbas-2/+1
2025-07-07Rollup merge of #143340 - nabijaczleweli:awhile, r=mati865Matthias Krüger-2/+2
awhile -> a while where appropriate
2025-07-07UWP: link ntdll functions using raw-dylibChris Denton-60/+9
2025-07-07std: fix typo in `std::path`xizheyin-2/+2
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-06Auto merge of #141829 - dvdsk:sleep_until_linux, r=cuviper,RalfJungbors-25/+219
Specialize sleep_until implementation for unix (except mac) related tracking issue: https://github.com/rust-lang/rust/issues/113752 Supersedes https://github.com/rust-lang/rust/pull/118480 for the reasons see: https://github.com/rust-lang/rust/issues/113752#issuecomment-2902594469 Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos etc. Other platforms like wasi, macos/ios/tvos/watchos and windows will follow in later separate PR's (once this is merged).
2025-07-06sleep_until: add clock_nanosleep support to Miridvdsk-0/+1
The clock_nanosleep support is there to allow code using `sleep_until` to run under Miri. Therefore the implementation is minimal. - Only the clocks REALTIME and MONOTONIC are supported. The first is supported simply because it was trivial to add not because it was needed for sleep_until. - The only supported flag combinations are no flags or TIMER_ABSTIME only. If an unsupported flag combination or clock is passed in this throws unsupported.
2025-07-06sleep_until: use clock_nanosleep where possibledvdsk-25/+218
Using clock nanosleep leads to more accurate sleep times on platforms where it is supported. To enable using clock_nanosleep this makes `sleep_until` platform specific. That unfortunatly requires identical placeholder implementations for the other platforms (windows/mac/wasm etc). we will land platform specific implementations for those later. See the `sleep_until` tracking issue. This requires an accessors for the Instant type. As that accessor is only used on the platforms that have clock_nanosleep it is marked as allow_unused. 32bit time_t targets do not use clock_nanosleep atm, they instead rely on the same placeholder as the other platforms. We could make them use clock_nanosleep too in the future using `__clock_nanosleep_time64`. __clock_nanosleep_time64 is documented at: https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html
2025-07-06Rollup merge of #143470 - Ayush1325:uefi-tcp4-recv, r=joshtriplettMatthias Krüger-6/+52
std: sys: net: uefi: tcp4: Implement read - A blocking implementation of tcp4 read. - Basically a copy of [write](https://github.com/rust-lang/rust/pull/141532)
2025-07-05fix(lib-std-fs): handle `usize` overflow in `read` & `read_to_string`Ricardo Fernández Serrata-2/+2
2025-07-04Rollup merge of #143086 - SciMind2460:patch-2, r=workingjubileeJubilee-1/+1
Update poison.rs to fix the typo (sys->sync)
2025-07-05std: sys: net: uefi: tcp4: Implement readAyush Singh-6/+52
A blocking implementation of tcp4 read. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-05Rollup merge of #141532 - Ayush1325:uefi-tcp4-send, r=tgross35Matthias Krüger-6/+53
std: sys: net: uefi: tcp4: Implement write A blocking implementation of tcp4 write.
2025-07-04std: sys: net: uefi: tcp4: Implement writeAyush Singh-6/+53
A blocking implementation of tcp4 write. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-04Rollup merge of #143387 - dpaoliello:shouldpanicfn, r=bjorn3Matthias Krüger-2/+2
Make __rust_alloc_error_handler_should_panic a function Fixes rust-lang/rust#143253 `__rust_alloc_error_handler_should_panic` is a static but was being exported as a function. For most targets this doesn't matter, but Arm64EC Windows uses different decorations for exported variables vs functions, hence it fails to link when `-Z oom=abort` is enabled. We've had issues in the past with statics like this (see rust-lang/rust#141061) but the tldr; is that Arm64EC needs symbols correctly exported as either a function or data, and data MUST and MUST ONLY be marked `dllimport` when the symbol is being imported from another binary, which is non-trivial to calculate for these compiler-generated statics. So, instead, the easiest thing to do is to make `__rust_alloc_error_handler_should_panic` a function instead. Since `__rust_alloc_error_handler_should_panic` isn't involved in any linking shenanigans, I've marked it as `AlwaysInline` with the hopes that the various backends will see that it is just returning a constant and perform the same optimizations as the previous implementation. r? `@bjorn3`
2025-07-03Make __rust_alloc_error_handler_should_panic a functionDaniel Paoliello-2/+2
2025-07-03Rollup merge of #134006 - klensy:typos, r=nnethercoteJana Dönszelmann-15/+15
setup typos check in CI This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying? Also includes commits with actual typo fixes. MCP: https://github.com/rust-lang/compiler-team/issues/817 typos check currently turned for: * ./compiler * ./library * ./src/bootstrap * ./src/librustdoc After merging, PRs which enables checks for other crates (tools) can be implemented too. Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr. Check typos: `python x.py test tidy --extra-checks=spellcheck` Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo) Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03setup CI and tidy to use typos for spellchecking and fix few typosklensy-15/+15
2025-07-02awhile -> a while where appropriateнаб-2/+2
2025-07-02Rollup merge of #141847 - xizheyin:141837, r=jhprattMatthias Krüger-15/+41
Explain `TOCTOU` on the top of `std::fs`, and reference it in functions Fixes rust-lang/rust#141837 r? ``````@workingjubilee``````
2025-07-02Auto merge of #142974 - cuviper:stage0-bump, r=Mark-Simulacrumbors-24/+22
Update stage0 to 1.89.0-beta.1 - Update version placeholders - Update stage0 to 1.89.0-beta.1 - Update `STAGE0_MISSING_TARGETS` - Update `cfg(bootstrap)` r? `@Mark-Simulacrum` try-job: dist-i586-gnu-i586-i686-musl
2025-07-01Update `cfg(bootstrap)`Josh Stone-2/+0
2025-07-01Update version placeholdersJosh Stone-22/+22
2025-07-01Rollup merge of #142760 - epage:lock, r=tgross35Guillaume Gomez-6/+6
docs(fs): Touch up grammar on lock api
2025-07-01Upgrade the `fortanix-sgx-abi` dependencyTrevor Gross-2/+2
0.6.1 removes the `compiler-builtins` dependency, part of RUST-142265. The breaking change from 0.5 to 0.6 is for an update to the `insecure_time` API [1]. I validated that `./x c library --target x86_64-fortanix-unknown-sgx` completes successfully with this change. Link: https://github.com/fortanix/rust-sgx/commit/a34e9767f37d6585c18bdbd31cddcadc56670d57 [1]