about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2022-11-20Rollup merge of #104537 - HintringerFabian:docs_default_min_stack_size, ↵Matthias Krüger-3/+2
r=the8472 fix std::thread docs are unclear regarding stack sizes Improves the documentation about the default stack size of a spawned thread Fixes #102671
2022-11-20Add get_many_mut methods to sliceMarvin Löbel-0/+1
2022-11-20cfg(miri) no longer needed in sys/unix/time.rsRalf Jung-2/+2
2022-11-20Improve documentation of Stack sizeFabian Hintringer-3/+2
2022-11-19Add unstable `type_ascribe` macroNilstrieb-0/+8
This macro serves as a placeholder for future type ascription syntax to make sure that the semantic implementation keeps working.
2022-11-19Rollup merge of #104553 - mwillsey:asinh-acosh-accuracy, r=thomccDylan DPC-4/+32
Improve accuracy of asinh and acosh This PR addresses the inaccuracy of `asinh` and `acosh` identified by the [Herbie](http://herbie.uwplse.org/) tool, `@pavpanchekha,` `@finnbear` in #104548. It also adds a couple tests that failed in the existing implementations and now pass. Closes #104548 r? rust-lang/libs
2022-11-19Rollup merge of #104528 - WaffleLapkin:lazy_lock_docfix, r=matkladDylan DPC-3/+7
Properly link `{Once,Lazy}{Cell,Lock}` in docs See https://github.com/rust-lang/rust/issues/74465#issuecomment-1317947443
2022-11-18Rollup merge of #103594 - maniwani:fix-issue-91417, r=thomccMatthias Krüger-9/+24
Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targets This is a duplicate of #94100 (since the original author is unresponsive), which resolves #91417. On `aarch64-apple-darwin` targets, the internal resolution of `Instant` is lower than that of `Duration`, so math between them becomes non-associative with small-enough durations. This PR makes this target use the standard Unix implementation (where `Instant` has 1ns resolution), but with `CLOCK_UPTIME_RAW` so it still returns the same values as `mach_absolute_time`[^1]. (Edit: I need someone to confirm that this still works, I do not have access to an M1 device.) [^1]: https://www.manpagez.com/man/3/clock_gettime/
2022-11-18Handle the case that even the filename array is unaligned.Thom Chiovoloni-5/+14
2022-11-17Don't assume `FILE_ID_BOTH_DIR_INFO` will be alignedThom Chiovoloni-5/+9
2022-11-17Improve accuracy of asinh and acoshMax Willsey-4/+32
2022-11-17Properly link `{Once,Lazy}{Cell,Lock}` in docsMaybe Waffle-3/+7
2022-11-16available_parallelism: Handle 0 cfs_period_usAdam Casey-2/+2
There seem to be some scenarios where `cpu.cfs_period_us` can contain `0` This causes a panic when calling `std::thread::available_parallelism()` as is done so from binaries built by `cargo test`, which was how the issue was discovered. I don't feel like `0` is a good value for `cpu.cfs_period_us`, but I also don't think applications should panic if this value is seen. This case is handled by other projects which read this information: - num_cpus: https://github.com/seanmonstar/num_cpus/blob/e437b9d9083d717692e35d917de8674a7987dd06/src/linux.rs#L207-L210 - ninja: https://github.com/ninja-build/ninja/pull/2174/files - dotnet: https://github.com/dotnet/runtime/blob/c4341d45acca3ea662cd8d71e7d71094450dd045/src/coreclr/pal/src/misc/cgroup.cpp#L481-L483 Before this change, this panic could be seen in environments setup as described above: ``` $ RUST_BACKTRACE=1 cargo test Finished test [unoptimized + debuginfo] target(s) in 3.55s Running unittests src/main.rs (target/debug/deps/x-9a42e145aca2934d) thread 'main' panicked at 'attempt to divide by zero', library/std/src/sys/unix/thread.rs:546:70 stack backtrace: 0: rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::panic 3: std::sys::unix::thread::cgroups::quota 4: std::sys::unix::thread::available_parallelism 5: std::thread::available_parallelism 6: test::helpers::concurrency::get_concurrency 7: test::console::run_tests_console 8: test::test_main 9: test::test_main_static 10: x::main at ./src/main.rs:1:1 11: core::ops::function::FnOnce::call_once at /tmp/rust-1.64-1.64.0-1/library/core/src/ops/function.rs:248:5 note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace. error: test failed, to rerun pass '--bin local-rabmq-amqpprox' ``` I've tested this change in an environment which has the bad setup and rebuilding the test executable against a fixed std library fixes the panic.
2022-11-16Rollup merge of #104401 - RalfJung:mpsc-leak, r=AmanieuMatthias Krüger-2/+3
avoid memory leak in mpsc test r? ```@Amanieu```
2022-11-15Rollup merge of #103734 - Mark-Simulacrum:fix-version-stabilized, r=JohnTitorMatthias Krüger-2/+2
Adjust stabilization version to 1.65.0 for wasi fds See https://github.com/rust-lang/rust/pull/103308#issuecomment-1292277645 for this ask. Backport of that PR to beta (1.65.0) will include a similar patch.
2022-11-15Auto merge of #104428 - matthiaskrgr:rollup-jo3078i, r=matthiaskrgrbors-3/+1
Rollup of 13 pull requests Successful merges: - #103842 (Adding Fuchsia compiler testing script, docs) - #104354 (Remove leading newlines from `NonZero*` doc examples) - #104372 (Update compiler-builtins) - #104380 (rustdoc: remove unused CSS `code { opacity: 1 }`) - #104381 (Remove dead NoneError diagnostic handling) - #104383 (Remove unused symbols and diagnostic items) - #104391 (Deriving cleanups) - #104403 (Specify language of code comment to generate document) - #104404 (Fix missing minification for static files) - #104413 ([llvm-wrapper] adapt for LLVM API change) - #104415 (rustdoc: fix corner case in search keyboard commands) - #104422 (Fix suggest associated call syntax) - #104426 (Add test for #102154) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-15Rollup merge of #104383 - WaffleLapkin:rustc_undiagnostic_item, ↵Matthias Krüger-2/+0
r=compiler-errors Remove unused symbols and diagnostic items As the title suggests, this removes unused symbols from `sym::` and `#[rustc_diagnostic_item]` annotations that weren't mentioned anywhere. Originally I tried to use grep, to find symbols and item names that are never mentioned via `sym::name`, however this produced a lot of false positives (?), for example clippy matching on `Symbol::as_str` or macros "implicitly" adding `sym::`. I ended up fixing all these false positives (?) by hand, but tbh I'm not sure if it was worth it...
2022-11-15Rollup merge of #104372 - Ayush1325:compiler-builtins, r=JohnTitorMatthias Krüger-1/+1
Update compiler-builtins This was originally a part of https://github.com/rust-lang/rust/pull/100316. However, extracting it to a seperate PR should help with any extra testing that might be needed. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-14Rollup merge of #101967 - jmillikin:linux-abstract-socket-addr, r=joshtriplettMatthias Krüger-95/+140
Move `unix_socket_abstract` feature API to `SocketAddrExt`. The pre-stabilized API for abstract socket addresses exposes methods on `SocketAddr` that are only enabled for `cfg(any(target_os = "android", target_os = "linux"))`. Per discussion in <https://github.com/rust-lang/rust/issues/85410>, moving these methods to an OS-specific extension trait is required before stabilization can be considered. This PR makes four changes: 1. The internal module `std::os::net` contains logic for the unstable feature `tcp_quickack` (https://github.com/rust-lang/rust/issues/96256). I moved that code into `linux_ext/tcp.rs` and tried to adjust the module tree so it could accommodate a second unstable feature there. 2. Moves the public API out of `impl SocketAddr`, into `impl SocketAddrExt for SocketAddr` (the headline change). 3. The existing function names and docs for `unix_socket_abstract` refer to addresses as being created from abstract namespaces, but a more accurate description is that they create sockets in *the* abstract namespace. I adjusted the function signatures correspondingly and tried to update the docs to be clearer. 4. I also tweaked `from_abstract_name` so it takes an `AsRef<[u8]>` instead of `&[u8]`, allowing `b""` literals to be passed directly. Issues: 1. The public module `std::os::linux::net` is marked as part of `tcp_quickack`. I couldn't figure out how to mark a module as being part of two unstable features, so I just left the existing attributes in place. My hope is that this will be fixed as a side-effect of stabilizing either feature.
2022-11-14macos, aarch64, and not(miri)Cameron-2/+2
2022-11-14std: move `ReentrantMutex` to `sync`joboet-4/+5
2022-11-14avoid memory leak in mpsc testRalf Jung-2/+3
2022-11-14Auto merge of #104387 - Manishearth:rollup-9e551p5, r=Manishearthbors-1/+12
Rollup of 9 pull requests Successful merges: - #103709 (ci: Upgrade dist-x86_64-netbsd to NetBSD 9.0) - #103744 (Upgrade cc for working is_flag_supported on cross-compiles) - #104105 (llvm: dwo only emitted when object code emitted) - #104158 (Return .efi extension for EFI executable) - #104181 (Add a few known-bug tests) - #104266 (Regression test for coercion of mut-ref to dyn-star) - #104300 (Document `Path::parent` behavior around relative paths) - #104304 (Enable profiler in dist-s390x-linux) - #104362 (Add `delay_span_bug` to `AttrWrapper::take_for_recovery`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-13Rollup merge of #104300 - tbu-:pr_path_parent_caveats, r=Mark-SimulacrumManish Goregaokar-1/+12
Document `Path::parent` behavior around relative paths A relative path with just one component will return `Some("")` as its parent, which wasn't clear to me from the documentation. The parent of `""` is `None`, which was missing from the documentation as well.
2022-11-14Auto merge of #103858 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-1/+1
Bump bootstrap compiler to 1.66 This PR: - Bumps version placeholders to release - Bumps to latest beta - cfg-steps code r? `@pietroalbini`
2022-11-13Auto merge of #103894 - mati865:gnullvm-libunwind-changes, r=thomccbors-1/+1
Change the way libunwind is linked for *-windows-gnullvm targets I have no idea why previous way works for `x86_64-fortanix-unknown-sgx` (assuming it actually works...) but not for `gnullvm`. It fails when linking libtest during Rust build (unless somebody adds `RUSTFLAGS='-Clinkarg=-lunwind'`). Also fixes exception handling on AArch64.
2022-11-13just use `libc::clockid_t`Cameron-8/+3
2022-11-13Fix non-associativity of `Instant` math on `aarch64-apple-darwin` targetsJoy-3/+23
2022-11-13Remove unused diagnostic itemsMaybe Waffle-2/+0
2022-11-13Update compiler-builtinsAyush Singh-1/+1
This was originally a part of https://github.com/rust-lang/rust/pull/100316. However, extracting it to a seperate PR should help with any extra testing that might be needed. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2022-11-13Auto merge of #93563 - ibraheemdev:crossbeam-channel, r=Amanieubors-2848/+2739
Merge crossbeam-channel into `std::sync::mpsc` This PR imports the [`crossbeam-channel`](https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel#crossbeam-channel) crate into the standard library as a private module, `sync::mpmc`. `sync::mpsc` is now implemented as a thin wrapper around `sync::mpmc`. The primary purpose of this PR is to resolve https://github.com/rust-lang/rust/issues/39364. The public API intentionally remains the same. The reason https://github.com/rust-lang/rust/issues/39364 has not been fixed in over 5 years is that the current channel is *incredibly* complex. It was written many years ago and has sat mostly untouched since. `crossbeam-channel` has become the most popular alternative on crates.io, amassing over 30 million downloads. While crossbeam's channel is also complex, like all fast concurrent data structures, it avoids some of the major issues with the current implementation around dynamic flavor upgrades. The new implementation decides on the datastructure to be used when the channel is created, and the channel retains that structure until it is dropped. Replacing `sync::mpsc` with a simpler, less performant implementation has been discussed as an alternative. However, Rust touts itself as enabling *fearless concurrency*, and having the standard library feature a subpar implementation of a core concurrency primitive doesn't feel right. The argument is that slower is better than broken, but this PR shows that we can do better. As mentioned before, the primary purpose of this PR is to fix https://github.com/rust-lang/rust/issues/39364, and so the public API intentionally remains the same. *After* that problem is fixed, the fact that `sync::mpmc` now exists makes it easier to fix the primary limitation of `mpsc`, the fact that it only supports a single consumer. spmc and mpmc are two other common concurrency patterns, and this change enables a path to deprecating `mpsc` and exposing a general `sync::channel` module that supports multiple consumers. It also implements other useful methods such as `send_timeout`. That said, exposing MPMC and other new functionality is mostly out of scope for this PR, and it would be helpful if discussion stays on topic :) For what it's worth, the new implementation has also been shown to be more performant in [some basic benchmarks](https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel/benchmarks#results). cc `@taiki-e` r? rust-lang/libs
2022-11-12avoid using channels in thread-local testsIbraheem Ahmed-22/+44
2022-11-12avoid calling `thread::current` in channel destructorIbraheem Ahmed-13/+11
2022-11-12Use correct EH personality on `*-windows-gnu-*`Mateusz Mikuła-1/+1
2022-11-12Rollup merge of #102049 - fee1-dead-contrib:derive_const, r=oli-obkDylan DPC-0/+4
Add the `#[derive_const]` attribute Closes #102371. This is a minimal patchset for the attribute to work. There are no restrictions on what traits this attribute applies to. r? `````@oli-obk`````
2022-11-12Auto merge of #103150 - joboet:remove_lock_wrappers, r=m-ou-sebors-653/+404
Remove lock wrappers in `sys_common` This moves the lazy allocation to `sys` (SGX and UNIX). While this leads to a bit more verbosity, it will simplify future improvements by making room in `sys_common` for platform-independent implementations. This also removes the condvar check on SGX as it is not necessary for soundness and will be removed anyway once mutex has been made movable. For simplicity's sake, `libunwind` also uses lazy allocation now on SGX. This will require an update to the C definitions before merging this (CC `@raoulstrackx).` r? `@m-ou-se`
2022-11-11Document `Path::parent` behavior around relative pathsTobias Bucher-1/+12
A relative path with just one component will return `Some("")` as its parent, which wasn't clear to me from the documentation. The parent of `""` is `None`, which was missing from the documentation as well.
2022-11-10Rollup merge of #104060 - ink-feather-org:const_hash, r=fee1-deadManish Goregaokar-3/+7
Make `Hash`, `Hasher` and `BuildHasher` `#[const_trait]` and make `Sip` const `Hasher` This PR enables using Hashes in const context. r? ``@fee1-dead``
2022-11-09tidyIbraheem Ahmed-5/+4
2022-11-09spin less in `mpsc::SyncSender::send`Ibraheem Ahmed-1/+1
2022-11-09remove extra spinning from `mpsc` parkerIbraheem Ahmed-15/+0
2022-11-09`sync::mpsc`: quadratic backoffIbraheem Ahmed-2/+3
2022-11-09`sync::mpsc`: reload state after spinning on CAS failureIbraheem Ahmed-8/+8
2022-11-09remove extra spinning from `mpsc::Receiver::recv`Ibraheem Ahmed-26/+6
2022-11-09remove mention of rust-lang#39364 from mpsc docsIbraheem Ahmed-28/+0
2022-11-09add test case for rust-lang#39364Ibraheem Ahmed-0/+14
2022-11-09implement `sync::mpsc` as a wrapper around `sync::mpmc`Ibraheem Ahmed-2798/+24
2022-11-09initial port of crossbeam-channelIbraheem Ahmed-0/+2694
2022-11-09`IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation.Abhijit Gadgil-0/+9
Added documentation for IPv6 Addresses `IN6ADDR_ANY_INIT` also known as `in6addr_any` and `IN6ADDR_LOOPBACK_INIT` also known as `in6addr_loopback` similar to `INADDR_ANY` for IPv4 Addresses.
2022-11-08Test const `Hash`, fix nitsonestacked-1/+1