about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2025-10-02Rollup merge of #146281 - Jules-Bertholet:static-align-thread-local, ↵Matthias Krüger-72/+410
r=Mark-Simulacrum Support `#[rustc_align_static]` inside `thread_local!` Tracking issue: rust-lang/rust#146177 ```rust thread_local! { #[rustc_align_static(64)] static SO_ALIGNED: u64 = const { 0 }; } ``` This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case. r? libs ``@rustbot`` label A-attributes A-macros A-thread-locals F-static_align T-libs
2025-10-01Fix memory leak in `os` implJules Bertholet-31/+72
2025-10-01Rollup merge of #147213 - ivmarkov:fix-hostname-espidf, r=joboetStuart Cook-1/+1
Fix broken STD build for ESP-IDF PRs rust-lang/rust#147162 and rust-lang/rust#146937 did [broke](https://github.com/esp-rs/esp-idf-sys/actions/runs/18151791720/job/51663969786) the STD build for `target_os = "espidf"` because that target [does not have neither a `gethostname`, not a `libc::_SC_HOST_NAME_MAX` by default](https://github.com/espressif/esp-idf/issues/14849). While there is a [3rd party component for this syscall](https://components.espressif.com/components/espressif/sock_utils/versions/0.2.2/readme) in the ESP-IDF component registry, I don't think we should use it, because it does not come with ESP-IDF by default. Therefore, the one-liner fix just re-routes ESP-IDF into the `unsupported` branch.
2025-10-01Fix broken STD build for ESP-IDFivmarkov-1/+1
2025-10-01Auto merge of #147198 - matthiaskrgr:rollup-b0ryvvu, r=matthiaskrgrbors-3/+25
Rollup of 6 pull requests Successful merges: - rust-lang/rust#143069 (Add fast-path for accessing the current thread id) - rust-lang/rust#146518 (Improve the documentation around `ZERO_AR_DATE`) - rust-lang/rust#146596 (Add a dummy codegen backend) - rust-lang/rust#146617 (Don’t suggest foreign `doc(hidden)` types in "the following other types implement trait" diagnostics) - rust-lang/rust#146635 (cg_llvm: Stop using `as_c_char_ptr` for coverage-related bindings) - rust-lang/rust#147184 (Fix the bevy implied bounds hack for the next solver) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-30Add fast-path for accessing the current thread idJosh Simmons-3/+25
Accessing the thread id is often used in profiling and debugging, as well as some approaches for sound single-threaded access to data. Currently the only way to access the thread id is by first obtaining a handle to the current thread. While this is not exactly slow, it does require an atomic inc-ref and dec-ref operation, as well as the injection of `Thread`'s drop code into the caller. This publicly exposes the existing fast-path for accessing the current thread id.
2025-09-30Rollup merge of #142506 - clarfonthey:path-trailing-sep, r=joboetMatthias Krüger-4/+221
Add `Path::has_trailing_sep` and related methods Implements rust-lang/libs-team#335. Tracking issue: rust-lang/rust#142503 Notable differences from ACP: * `trim_trailing_sep` was added to `Path` since it felt reasonable to ensure that the inverse operation was available. * Per suggestion of `@kennytm,` added `push_trailing_sep` and `pop_trailing_sep` to `PathBuf` in addition to `set_trailing_sep`. This also updates some of the docs on various `Path` methods to use the term "trailing separator" instead of "trailing slash" for consistency.
2025-09-29Rollup merge of #146937 - joboet:gethostname, r=Mark-SimulacrumMatthias Krüger-78/+224
std: implement `hostname` Resolves https://github.com/rust-lang/libs-team/issues/330 Tracking issue: https://github.com/rust-lang/rust/issues/135142 This is based on rust-lang/rust#135141, but I've reimplemented the UNIX version, which now: * uses `sysconf(_SC_HOST_NAME_MAX)` as an initial buffer length * returns `OutOfMemory` if the `Vec` allocation fails * retries the operation if it detects that the name returned by `gethostname` was truncated Additionally, as part of the rebase, I had to move some WinSock abstractions (initialisation and error access) to `sys::pal` so that they can be accessed from `sys::net::hostname`. CC ``@orowith2os`` (and thank you for your work!)
2025-09-29std: implement `hostname`joboet-1/+140
2025-09-29Auto merge of #147090 - Noratrieb:immediate-abort-stack-overflow, r=joboetbors-2/+13
Skip stack overflow handler for panic=immediate-abort std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately *don't* want nice messages, they want minimum binary size. Therefore, skip the entire guard signal handler setup, which saves a lot of bytes. I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo. `size` reports significant savings: ``` text data bss dec hex filename 15252 1032 104 16388 4004 tiny-before 6881 964 48 7893 1ed5 tiny-after2 ``` `nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`. The impact on the error message is minimal, as the message was already missing. before: ``` fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort) ``` after: ``` fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error) ``` I didn't test the Windows part, but it likely also has savings.
2025-09-28Rollup merge of #140482 - devnexen:tcp_deferaccept_toduration, r=joboetMatthias Krüger-17/+27
std::net: update tcp deferaccept delay type to Duration. See comment [here](https://github.com/rust-lang/rust/issues/119639#issuecomment-2839330337).
2025-09-28Rollup merge of #147110 - SebastianSpeitel:patch-1, r=saethlinMatthias Krüger-1/+1
Fix typo Noticed this when looking at the source on doc.rust-lang.org
2025-09-28Rollup merge of #147093 - jackpot51:redox-path, r=bjorn3Matthias Krüger-1/+1
redox: switch to colon as path separator We recently changed this in order to better comply with assumptions about Unix-like systems. The current PATH is set to `/usr/bin` with no separators in order to ease the transition.
2025-09-28Rollup merge of #146788 - sysrex:146756/discord_invite, r=workingjubileeMatthias Krüger-2/+2
chore: removes deprecated discord. This PR just changes the wording of the contributing document to remove the deprecated Discord. Fixes https://github.com/rust-lang/rust/issues/146756.
2025-09-28Fix typoSebastian Speitel-1/+1
2025-09-27Hoist non-platform-specific code out of `thread_local_inner!`Jules Bertholet-16/+6
2025-09-27fix build for androidDavid Carlier-0/+1
2025-09-27redox: switch to colon as path separatorJeremy Soller-1/+1
2025-09-27Skip stack overflow handler for panic=immediate-abortNoratrieb-2/+13
std installs guard pages and a signal handler to ensure that stackoverflows 1) terminate abruptly and 2) print an nice message. Even for panic=immediate-abort, 1) is desirable, we don't want silent data corruption there. But 2) is completely unnecessary, as users deliberately *don't* want nice messages, they want minimum binary size. Therefore, skip the entire guard signal handler setup, which saves a lot of bytes. I tested this with a hello world binary using fat LTO, build-std, panic=immediate-abort, opt-level=s, strip=debuginfo. `size` reports significant savings: ``` text data bss dec hex filename 15252 1032 104 16388 4004 tiny-before 6881 964 48 7893 1ed5 tiny-after2 ``` `nm -U` goes from 71 to 56, getting rid of a bunch of stack overflow related symbols. The disk size goes from `31k` to `24k`. The impact on the error message is minimal, as the message was already missing. before: ``` fish: Job 1, './tiny-so-before' terminated by signal SIGABRT (Abort) ``` after: ``` fish: Job 1, './tiny-so-after' terminated by signal SIGSEGV (Address boundary error) ```
2025-09-27Remove `cfg(bootstrap)` for `doc_cfg` feature following #141925Guillaume Gomez-6/+1
2025-09-27Fix autodiff feature activationGuillaume Gomez-1/+0
2025-09-27fmtGuillaume Gomez-5/+1
2025-09-27Remove `doc_cfg_hide` featureGuillaume Gomez-1/+2
2025-09-27Strenghten checks for `doc(auto_cfg(show/hide))` attributesGuillaume Gomez-7/+1
2025-09-27Implement RFC 3631Guillaume Gomez-1/+15
2025-09-27Auto merge of #146636 - Mark-Simulacrum:bootstrap-bump, r=jieyouxubors-15/+15
Bump bootstrap compiler to 1.91 beta https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday
2025-09-26Update CURRENT_RUSTC_VERSION post-bumpMark Rousskov-15/+15
2025-09-26Support `#[rustc_align_static]` inside `thread_local!`Jules Bertholet-72/+379
2025-09-26std::net: update tcp deferaccept delay type to Duration.David Carlier-17/+26
2025-09-26Rollup merge of #145113 - petrochenkov:lessfinalize, r=lcnrMatthias Krüger-1/+1
resolve: Do not finalize shadowed bindings I.e. do not mark them as used, or non-speculatively loaded, or similar. Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-26Rollup merge of #147049 - vexide:vex-std, r=workingjubileeMatthias Krüger-1/+1
std: fix warning in VEXos stdio module Fixes building `std` on the `armv7a-vex-v5` target due to an unnecessarily mutable argument in `Stdin`. This was a stupid oversight on my part towards the end of rust-lang/rust#145973's review process. Missed a warning and had a bad bootstrap config that didn't tell me about it when testing changes.
2025-09-25std: fix warning in VEXos stdio moduleTropical-1/+1
2025-09-25resolve: Do not finalize shadowed bindingsVadim Petrochenkov-1/+1
I.e. do not mark them as used, or non-speculative loaded, or similar. Previously they were sometimes finalized during early resolution, causing issues like https://github.com/rust-lang/rust/pull/144793#issuecomment-3168108005.
2025-09-25Auto merge of #147019 - Zalathar:rollup-boxzbmo, r=Zalatharbors-3/+989
Rollup of 14 pull requests Successful merges: - rust-lang/rust#145067 (RawVecInner: add missing `unsafe` to unsafe fns) - rust-lang/rust#145277 (Do not materialise X in [X; 0] when X is unsizing a const) - rust-lang/rust#145973 (Add `std` support for `armv7a-vex-v5`) - rust-lang/rust#146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization) - rust-lang/rust#146735 (unstably constify float mul_add methods) - rust-lang/rust#146737 (f16_f128: enable some more tests in Miri) - rust-lang/rust#146766 (Add attributes for #[global_allocator] functions) - rust-lang/rust#146905 (llvm: update remarks support on LLVM 22) - rust-lang/rust#146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`) - rust-lang/rust#147005 (Small string formatting cleanup) - rust-lang/rust#147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`) - rust-lang/rust#147008 (bootstrap.py: Respect build.jobs while building bootstrap tool) - rust-lang/rust#147013 (rustdoc: Fix documentation for `--doctest-build-arg`) - rust-lang/rust#147015 (Use `LLVMDisposeTargetMachine`) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-25Rollup merge of #147007 - LawnGnome:tosocketaddrs-doc, r=tgross35Stuart Cook-0/+2
Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs` Although the examples below this list do imply that there's an impl of `ToSocketAddrs` for `&[SocketAddr]`, it's not actually noted in the list of default implementations.
2025-09-25Rollup merge of #146735 - Qelxiros:const_mul_add, r=tgross35,RalfJungStuart Cook-2/+5
unstably constify float mul_add methods Tracking issue: rust-lang/rust#146724 r? `@tgross35`
2025-09-25Rollup merge of #145973 - vexide:vex-std, r=tgross35Stuart Cook-1/+982
Add `std` support for `armv7a-vex-v5` This PR adds standard library support for the VEX V5 Brain (`armv7a-vex-v5` target). It is more-or-less an updated version of the library-side work done in rust-lang/rust#131530. This was a joint effort between me, `@lewisfm,` `@max-niederman,` `@Gavin-Niederman` and several other members of the [`vexide` project](https://github.com/vexide/). ## Background VEXos is a fairly unconventional operating system, with user code running in a restricted enviornment with regards to I/O capabilities and whatnot. As such, several OS-dependent APIs are unsupported or have partial support (such as `std::net`, `std::process`, and most of `std::thread`). A more comprehensive list of what does or doesn't work is outlined in the [updated target documentation](https://github.com/vexide/rust/blob/vex-std/src/doc/rustc/src/platform-support/armv7a-vex-v5.md). Despite these limitations, we believe that `libstd` support on this target still has value to users, especially given the popular use of this hardware for educational purposes. For some previous discussion on this matter, see [this comment](https://github.com/rust-lang/rust/pull/131530#issuecomment-2432856841). ## SDK Linkage VEXos doesn't really ship with an official `libc` or POSIX-style platform API (and though it does port newlib, these are stubbed on top of the underlying SDK). Instead, VEX provides their own SDK for calling platform APIs. Their official SDK is kept proprietary (with public headers), though open-source implementations exist. Following the precedent of the `armv6k-nintendo-3ds` team's work in rust-lang/rust#95897, we've opted not to directly link `libstd` to any SDK with the expectation that users will provide their own with one of the following options: - [`vex-sdk-download`](https://github.com/vexide/vex-sdk/tree/main/packages/vex-sdk-download), which downloads an official proprietary SDK from VEX using a build script. - [`vex-sdk-jumptable`](https://crates.io/crates/vex-sdk-jumptable), which is a compatible, open-source reimplementation of the SDK using firmware jumps. - [`vex-sdk-pros`](https://github.com/vexide/vex-sdk/tree/main/packages/vex-sdk-pros), which uses the [PROS kernel](https://github.com/purduesigbots/pros) as a provider for SDK functions. - Linking their own implementation or stubbing the functions required by libstd. The `vex-sdk` crate used in the VEXos PAL provides `libc`-style FFI bindings for any compatible system library, so any of these options *should* work fine. A functional demo project using `vex-sdk-download` can be found [here](https://github.com/vexide/armv7a-vex-v5-demo/tree/main). ## Future Work This PR implements virtually everything we are currently able to implement given the current capabilities of the platform. The exception to this is file directory enumeration, though the implementation of that is sufficiently [gross enough](https://github.com/vexide/vexide/blob/c6c5bad11e035cf4e51d429dca7e427210185ed4/packages/vexide-core/src/fs/mod.rs#L987) to drive us away from supporting this officially. Additionally, I have a working branch implementing the `panic_unwind` runtime for this target, which is something that would be nice to see in the future, though given the volume of compiler changes i've deemed it out-of-scope for this PR.
2025-09-25Auto merge of #147003 - matthiaskrgr:rollup-b5z9uiz, r=matthiaskrgrbors-26/+56
Rollup of 7 pull requests Successful merges: - rust-lang/rust#146556 (Fix duration_since panic on unix when std is built with integer overflow checks) - rust-lang/rust#146679 (Clarify Display for error should not include source) - rust-lang/rust#146753 (Improve the pretty print of UnstableFeature clause) - rust-lang/rust#146894 (Improve derive suggestion of const param) - rust-lang/rust#146950 (core: simplify `CStr::default()`) - rust-lang/rust#146958 (Fix infinite recursion in Path::eq with String) - rust-lang/rust#146971 (fix ICE in writeback due to bound regions) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-24Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`.Adam Harvey-0/+2
Although the examples below this list do imply that there's an impl of `ToSocketAddrs` for `&[SocketAddr]`, it's not actually noted in the list of default implementations.
2025-09-24Rollup merge of #146958 - el-ev:fix_path_string_eq_recurse, r=joboetMatthias Krüger-9/+19
Fix infinite recursion in Path::eq with String - Closes [after beta backport] rust-lang/rust#146940
2025-09-24Repro duration_since regression from issue 146228Stepan Koltsov-17/+37
2025-09-24unstably constify float mul_add methodsJeremy Smart-2/+5
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-09-24Rollup merge of #146964 - Ayush1325:close-protocol, r=joboetMatthias Krüger-0/+4
library: std: sys: pal: uefi: Add some comments I seemed to have forgotten that since I am using GET_PROTOCOL attribute for the std usecases, I did not need to close the protocols explicitly. So adding these comments as a note to future self not to waste time on the same thing again.
2025-09-24std: add support for armv7a-vex-v5 targetTropical-1/+982
Co-authored-by: Lewis McClelland <lewis@lewismcclelland.me>
2025-09-24Fix infinite recursion in Path::eq with StringIris Shi-9/+19
2025-09-24chore: remove discord references from the std library as wellsysrex-2/+2
2025-09-24library: std: sys: pal: uefi: Add some commentsAyush Singh-0/+4
I seemed to have forgotten that since I am using GET_PROTOCOL attribute for the std usecases, I did not need to close the protocols explicitly. So adding these comments as a note to future self not to waste time on the same thing again. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-09-23Rollup merge of #146904 - peter-lyons-kehl:140368_data_ptr_const_fn, r=AmanieuMatthias Krüger-5/+5
#140368 Mutex/RwLock/ReentrantLock::data_ptr to be const fn
2025-09-23Rollup merge of #146632 - ctz:jbp-adaptor-spelling, r=petrochenkovMatthias Krüger-1/+1
Fix uses of "adaptor" These docs are in en_US, so "adapter" is the correct spelling (and indeed used in the next line.) A second commit comes along for the ride to fix other instances in non-rustdoc comments.
2025-09-23std: move WinSock abstractions to `sys::pal`joboet-77/+84