about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2024-10-02Add `get_line` confusable to `Stdin::read_line()`Jaken Herman-0/+1
Add tests for addition of `#[rustc_confusables("get_line")]`
2024-10-02impl Default for Hash{Map,Set} iterators that don't already have itltdk-0/+80
2024-10-03Auto merge of #127912 - joboet:tls_dtor_thread_current, r=cuviperbors-132/+529
std: make `thread::current` available in all `thread_local!` destructors ... and thereby allow the panic runtime to always print the right thread name. This works by modifying the TLS destructor system to schedule a runtime cleanup function after all other TLS destructors registered by `std` have run. Unfortunately, this doesn't affect foreign TLS destructors, `thread::current` will still panic there. Additionally, the thread ID returned by `current_id` will now always be available, even inside the global allocator, and will not change during the lifetime of one thread (this was previously the case with key-based TLS). The mechanisms I added for this (`local_pointer` and `thread_cleanup`) will also allow finally fixing #111272 by moving the signal stack to a similar runtime-cleanup TLS variable.
2024-10-03Auto merge of #131148 - Urgau:hashbrown-0.15, r=Amanieubors-115/+56
Update hashbrown to 0.15 and adjust some methods This PR updates `hashbrown` to 0.15 in the standard library and adjust some methods as well as removing some as they no longer exists in Hashbrown it-self. - `HashMap::get_many_mut` change API to return array-of-Option - `HashMap::{replace_entry, replace_key}` are removed, FCP close [already finished](https://github.com/rust-lang/rust/issues/44286#issuecomment-2293825619) - `HashSet::get_or_insert_owned` is removed as it no longer exists in hashbrown Closes https://github.com/rust-lang/rust/issues/44286 r? `@Amanieu`
2024-10-02std: make `thread::current` available in all `thread_local!` destructorsjoboet-132/+529
2024-10-02Update hashbrown to 0.15 and adjust some methodsUrgau-115/+56
as well as removing some from std as they no longer exists in Hashbrown it-self.
2024-10-02mpmc doctest: make sure main thread waits for child threadsRalf Jung-22/+24
2024-10-01std: replace `LazyBox` with `OnceBox`joboet-284/+185
This PR replaces the `LazyBox` wrapper used to allocate the pthread primitives with `OnceBox`, which has a more familiar API mirroring that of `OnceLock`. This cleans up the code in preparation for larger changes like #128184 (from which this PR was split) and allows some neat optimizations, like avoid an acquire-load of the allocation pointer in `Mutex::unlock`, where the initialization of the allocation must have already been observed. Additionally, I've gotten rid of the TEEOS `Condvar` code, it's just a duplicate of the pthread one anyway and I didn't want to repeat myself.
2024-10-01Auto merge of #131098 - GuillaumeGomez:rollup-kk74was, r=GuillaumeGomezbors-1/+1
Rollup of 5 pull requests Successful merges: - #130630 (Support clobber_abi and vector/access registers (clobber-only) in s390x inline assembly) - #131042 (Instantiate binders in `supertrait_vtable_slot`) - #131079 (Update wasm-component-ld to 0.5.9) - #131085 (make test_lots_of_insertions test take less long in Miri) - #131088 (add fixme to remove LLVM_ENABLE_TERMINFO when minimal llvm version is 19) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-01Rollup merge of #131085 - RalfJung:miri-slow-test, r=tgross35Guillaume Gomez-1/+1
make test_lots_of_insertions test take less long in Miri This is by far the slowest `std` test in Miri, taking >2min in https://github.com/rust-lang/miri-test-libstd CI. So let's make this `count` smaller. The runtime should be quadratic in `count` so reducing it to around 2/3 of it's previous value should cut the total time down to less than half -- making it still the slowest test, but by less of a margin. (And this way we still insert >64 elements into the HashMap, in case that power of 2 matters.)
2024-10-01Auto merge of #126839 - obeis:mpmc, r=Amanieubors-49/+1732
Add multi-producer, multi-consumer channel (mpmc) Closes #125712 Tracking issue: #126840 r? m-ou-se
2024-10-01make test_lots_of_insertions test take less long in MiriRalf Jung-1/+1
2024-09-30Enable `f16` tests on non-GNU WindowsTrevor Gross-3/+3
There is a MinGW ABI bug that prevents `f16` and `f128` from being usable on `windows-gnu` targets. This does not affect MSVC; however, we have `f16` and `f128` tests disabled on all Windows targets. Update the gating to only affect `windows-gnu`, which means `f16` tests will be enabled. There is no effect for `f128` since the default fallback is `false`.
2024-09-30Rollup merge of #130961 - tgross35:f16-x86-apple, r=thomccTrevor Gross-3/+0
Enable `f16` tests on x86 Apple platforms These were disabled because Apple uses a special ABI for `f16`. `compiler-builtins` merged a fix for this in [1], which has since propagated to rust-lang/rust. Enable tests since there should be no remaining issues on these platforms. [1]: https://github.com/rust-lang/compiler-builtins/pull/675 try-job: x86_64-apple-1 try-job: x86_64-apple-2
2024-09-30Rollup merge of #130914 - compiler-errors:insignificant-dtor, r=AmanieuTrevor Gross-0/+1
Mark some more types as having insignificant dtor These were caught by https://github.com/rust-lang/rust/pull/129864#issuecomment-2376658407, which is implementing a lint for some changes in drop order for temporaries in tail expressions. Specifically, the destructors of `CString` and the bitpacked repr for `std::io::Error` are insignificant insofar as they don't have side-effects on things like locking or synchronization; they just free memory. See some discussion on #89144 for what makes a drop impl "significant"
2024-09-30Rollup merge of #129638 - nickrum:wasip2-net, r=alexcrichtonTrevor Gross-47/+506
Hook up std::net to wasi-libc on wasm32-wasip2 target One of the improvements of the `wasm32-wasip2` target over `wasm32-wasip1` is better support for networking. Right now, p2 is just re-using the `std::net` implementation from p1. This PR adds a new net module for p2 that makes use of net from `sys_common` and calls wasi-libc functions directly. There are currently a few limitations: - Duplicating a socket is not supported by WASIp2 (directly returns an error) - Peeking is not yet implemented in wasi-libc (we could let wasi-libc handle this, but I opted to directly return an error instead) - Vectored reads/writes are not supported by WASIp2 (the necessary functions are available in wasi-libc, but they call WASIp1 functions which do not support sockets, so I opted to directly return an error instead) - Getting/setting `TCP_NODELAY` is faked in wasi-libc (uses the fake implementation instead of returning an error) - Getting/setting `SO_LINGER` is not supported by WASIp2 (directly returns an error) - Setting `SO_REUSEADDR` is faked in wasi-libc (since this is done from `sys_common`, the fake implementation is used instead of returning an error) - Getting/setting `IPV6_V6ONLY` is not supported by WASIp2 and will always be set for IPv6 sockets (since this is done from `sys_common`, wasi-libc will return an error) - UDP broadcast/multicast is not supported by WASIp2 (since this is configured from `sys_common`, wasi-libc will return appropriate errors) - The `MSG_NOSIGNAL` send flag is a no-op because there are no signals in WASIp2 (since explicitly setting this flag would require a change to `sys_common` and the result would be exactly the same, I opted to not set it) Do those decisions make sense? While working on this PR, I noticed that there is a `std::os::wasi::net::TcpListenerExt` trait that adds a `sock_accept()` method to `std::net::TcpListener`. Now that WASIp2 supports standard accept, would it make sense to remove this? cc `@alexcrichton`
2024-09-30Win: Add test cases for renaming a directory while the target file is opened ↵George Tokmaji-0/+41
and for renaming over a non-empty directory
2024-09-30Win: Use `FILE_RENAME_FLAG_POSIX_SEMANTICS` for `std::fs::rename` if availableGeorge Tokmaji-4/+168
Windows 10 1601 introduced `FileRenameInfoEx` as well as `FILE_RENAME_FLAG_POSIX_SEMANTICS`, allowing for atomic renaming. If it isn't supported, we fall back to `FileRenameInfo`. This commit also replicates `MoveFileExW`'s behavior of checking whether the source file is a mount point and moving the mount point instead of resolving the target path.
2024-09-30Add multi-producer, multi-consumer channel (mpmc)Obei Sideg-49/+1732
2024-09-29Rollup merge of #130743 - YohDeadfall:net-nonblocking-doc, r=Mark-SimulacrumGuillaume Gomez-2/+2
Clarifications for set_nonblocking methods Closes #129903. The issue mentions that `send`, `recv` and other operations are interpreted by some users as methods of `TcpSocket` which led to confusion since it hasn't them. To fix it I added "system" into the documentation as being more precise for two reasons: * it's makes it clear that these names are system operations; * it doesn't point to the location of these methods like `libc` because not every system is POSIX compatible.
2024-09-29Auto merge of #128321 - BatmanAoD:catch-unwind-doc-update, r=Mark-Simulacrumbors-25/+60
Update `catch_unwind` doc comments for `c_unwind` Updates `catch_unwind` doc comments to indicate that catching a foreign exception _will no longer_ be UB. Instead, there are two possible behaviors, though it is not specified which one an implementation will choose. Nominated for t-lang to confirm that they are okay with making such a promise based on t-opsem FCP, or whether they would like to be included in the FCP. Related: https://github.com/rust-lang/rust/issues/74990, https://github.com/rust-lang/rust/issues/115285, https://github.com/rust-lang/reference/pull/1226
2024-09-29Fix std tests for wasm32-wasip2 targetNicola Krumschmidt-45/+125
2024-09-29Hook up std::net to wasi-libc on wasm32-wasip2 targetNicola Krumschmidt-2/+381
2024-09-28Enable `f16` tests on x86 Apple platformsTrevor Gross-3/+0
These were disabled because Apple uses a special ABI for `f16`. `compiler-builtins` merged a fix for this in [1], which has since propagated to rust-lang/rust. Enable tests since there should be no remaining issues on these platforms. [1]: https://github.com/rust-lang/compiler-builtins/pull/675
2024-09-28Auto merge of #129385 - tgross35:more-platforms-enable-f16, r=Mark-Simulacrumbors-14/+11
Enable `f16` tests on platforms that were missing conversion symbols The only requirement for `f16` support, aside from LLVM not crashing and no ABI issues, is that symbols to convert to and from `f32` are available. Since the update to compiler-builtins in https://github.com/rust-lang/rust/pull/125016, we now provide these on all platforms. This also enables `f16` math since there are no further requirements. Still excluded are platforms for which LLVM emits infinitely-recursing code. try-job: arm-android try-job: test-various try-job: x86_64-fuchsia
2024-09-28Update compiler_builtins to 0.1.130Trevor Gross-1/+1
This includes the following which add `__divtf3` and `__powtf2`, and do some feature cleanup: - https://github.com/rust-lang/compiler-builtins/pull/622 - https://github.com/rust-lang/compiler-builtins/pull/692 - https://github.com/rust-lang/compiler-builtins/pull/614 - https://github.com/rust-lang/compiler-builtins/pull/694 The `cc` bump [1] was previously included but was reverted due to problems updating. [1]: https://github.com/rust-lang/compiler-builtins/pull/690
2024-09-28Rollup merge of #130922 - tyilo:udp-unspecified, r=ibraheemdevMatthias Krüger-2/+2
Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4
2024-09-28Rollup merge of #125404 - a1phyr:fix-read_buf-uses, r=workingjubileeMatthias Krüger-16/+88
Fix `read_buf` uses in `std` Following lib-team decision here: https://github.com/rust-lang/rust/issues/78485#issuecomment-2122992314 Guard against the pathological behavior of both returning an error and performing a read.
2024-09-27Enable `f16` on platforms that were missing conversion symbolsTrevor Gross-14/+11
The only requirement for `f16` support, aside from LLVM not crashing and no ABI issues, is that symbols to convert to and from `f32` are available. Since the update to compiler-builtins in [1], we now provide these on all platforms. This also enables `f16` math since there are no further requirements. Still excluded are platforms for which LLVM emits infinitely-recursing code. [1]: https://github.com/rust-lang/rust/pull/125016
2024-09-27Mark some more types as having insignificant dtorMichael Goulet-0/+1
2024-09-27Reference UNSPECIFIED instead of INADDR_ANY in join_multicast_v4Asger Hautop Drewsen-2/+2
2024-09-26Rollup merge of #130875 - folkertdev:naked-asm-bootstrap, r=tgross35Jubilee-1/+1
update `compiler-builtins` to 0.1.126 this requires the addition of a bootstrap variant of the new `naked_asm!` macro r? `@tgross35` extracted from https://github.com/rust-lang/rust/pull/128651
2024-09-26Rollup merge of #130846 - ChrisDenton:revert-break, r=NoratriebJubilee-170/+1
Revert Break into the debugger on panic (129019) This was talked about a bit at a recent libs meeting. While I think experimenting with this is worthwhile, I am nervous about this new behaviour reaching stable. We've already reverted on one tier 1 platform (Linux, https://github.com/rust-lang/rust/pull/130810) which means we have differing semantics on different tier 1 platforms. Also the fact it triggers even when `catch_unwind` is used to catch the panic means it can be very noisy in some projects. At the very least I think it could use some more discussion before being instantly stable. I think this could maybe be re-landed with an environment variable to control/override the behaviour. But that part would likely need a libs-api decision. cc ````@workingjubilee```` ````@kromych````
2024-09-27Rollup merge of #130861 - cuviper:sun-path-offset, r=ibraheemdevGuillaume Gomez-12/+9
Use `mem::offset_of!` for `sockaddr_un.sun_path` We don't need manual pointer math here anymore! try-job: dist-i686-msvc
2024-09-26Add `sun_path` to the fake doc `sockaddr_un`Josh Stone-1/+3
2024-09-26update `compiler_builtins` to `0.1.126`Folkert de Vries-1/+1
2024-09-25Use `&raw` in the standard libraryJosh Stone-111/+86
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-25Use `mem::offset_of!` for `sockaddr_un.sun_path`Josh Stone-11/+6
2024-09-25Rollup merge of #130842 - Noratrieb:tracking-issue-inprogress, r=jieyouxuMatthias Krüger-1/+1
Add tracking issue for io_error_inprogress I forgot to mention this in #130789
2024-09-25Rollup merge of #130811 - RalfJung:random, r=joboetMatthias Krüger-1/+2
add link from random() helper fn to extensive DefaultRandomSource docs
2024-09-25Revert Break into the debugger on panic (129019)Chris Denton-170/+1
2024-09-25Add tracking issue for io_error_inprogressnora-1/+1
2024-09-25Auto merge of #130816 - matthiaskrgr:rollup-jy25phv, r=matthiaskrgrbors-99/+225
Rollup of 6 pull requests Successful merges: - #130549 (Add RISC-V vxworks targets) - #130595 (Initial std library support for NuttX) - #130734 (Fix: ices on virtual-function-elimination about principal trait) - #130787 (Ban combination of GCE and new solver) - #130809 (Update llvm triple for OpenHarmony targets) - #130810 (Don't trap into the debugger on panics under Linux) r? `@ghost` `@rustbot` modify labels: rollup
2024-09-25Rollup merge of #130810 - kromych:master, r=workingjubileeMatthias Krüger-78/+1
Don't trap into the debugger on panics under Linux This breaks `rr`, see https://github.com/rust-lang/rust/pull/129019#issuecomment-2369361278 for the discussion CC `@khuey` `@workingjubilee`
2024-09-25Rollup merge of #130595 - no1wudi:master, r=ibraheemdevMatthias Krüger-21/+223
Initial std library support for NuttX This PR add the initial libstd support for NuttX platform (Tier 3), currently it depends on https://github.com/rust-lang/libc/pull/3909 which provide the essential libc definitions.
2024-09-25Rollup merge of #130549 - biabbas:riscv32_wrs_vxworks, r=nnethercoteMatthias Krüger-0/+1
Add RISC-V vxworks targets Risc-V 32 and RISC-V 64 targets are to be added in the target list.
2024-09-25add link from random() helper fn to extensive DefaultRandomSource docsRalf Jung-1/+2
2024-09-25Auto merge of #130803 - cuviper:file-buffered, r=joshtriplettbors-3/+109
Add `File` constructors that return files wrapped with a buffer In addition to the light convenience, these are intended to raise visibility that buffering is something you should consider when opening a file, since unbuffered I/O is a common performance footgun to Rust newcomers. ACP: https://github.com/rust-lang/libs-team/issues/446 Tracking Issue: #130804
2024-09-24Don't trap into the debugger on panics under Linuxkromych-78/+1
This breaks `rr`, see https://github.com/rust-lang/rust/pull/129019#issuecomment-2369361278 for the discussion CC @khuey @workingjubilee
2024-09-24Rollup merge of #130789 - aviramha:add_inprogress, r=NoratriebTrevor Gross-0/+8
add InProgress ErrorKind gated behind io_error_inprogress feature Follow up on https://github.com/rust-lang/libs-team/issues/92#issuecomment-2371666560