summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2021-05-22join_orders_after_tls_destructors: ensure thread 2 is launched before thread ↵Mohsen Zohrevandi-8/+9
1 enters TLS destructors
2021-05-22Use atomics in join_orders_after_tls_destructors testMohsen Zohrevandi-34/+88
std::sync::mpsc uses thread locals and depending on the order TLS dtors are run `rx.recv()` can panic when used in a TLS dtor.
2021-05-22Ensure TLS destructors run before thread joins in SGXMohsen Zohrevandi-11/+119
2021-05-04Revert "Add debug_assert_matches macro."Mark Rousskov-2/+2
This reverts commit 0a8e401188062f0c60c989978352663b1e25e70e.
2021-05-04Revert "Add assert_matches!(expr, pat)."Mark Rousskov-3/+2
This reverts commit eb18746bc6c6c5c710ad674873438cbad5894f06.
2021-04-30Auto merge of #84716 - joshtriplett:chroot, r=dtolnaybors-0/+33
Add std::os::unix::fs::chroot to change the root directory of the current process This is a straightforward wrapper that uses the existing helpers for C string handling and errno handling. Having this available is convenient for UNIX utility programs written in Rust, and avoids having to call the unsafe `libc::chroot` directly and handle errors manually, in a program that may otherwise be entirely safe code.
2021-04-30Auto merge of #84522 - CDirkx:cmath, r=yaahcbors-118/+34
Reuse `sys::unix::cmath` on other platforms Reuse `sys::unix::cmath` on all non-`windows` platforms. `unix` is chosen as the canonical location instead of `unsupported` or `common` because `unsupported` doesn't make sense semantically and `common` is reserved for code that is supported on all platforms. Also `unix` is already the home of some non-`windows` code that is technically not exclusive to `unix` like `unix::path`.
2021-04-30Add std::os::unix::fs::chroot to change the root directory of the current ↵Josh Triplett-0/+33
process This is a straightforward wrapper that uses the existing helpers for C string handling and errno handling. Having this available is convenient for UNIX utility programs written in Rust, and avoids having to call the unsafe `libc::chroot` directly and handle errors manually, in a program that may otherwise be entirely safe code.
2021-04-29Rollup merge of #84692 - r00ster91:var-var_os-vars, r=joshtriplettJack Huey-2/+11
Link between std::env::{var, var_os} and std::env::{vars, vars_os} In #84551 I linked between `std::env::{args, args_os}` and this PR does the same but for `std::env::{var, var_os}` and `std::env::{vars, vars_os}`. Now all of `std::env::{var, var_os, vars, vars_os, args, args_os}` should each mention their `_os` or non-`_os` equivalent in the docs so that you can easily navigate between them.
2021-04-29Rollup merge of #84590 - est31:array_into_iter, r=nikomatsakisJack Huey-2/+47
Point out that behavior might be switched on 2015 and 2018 too one day Reword documentation to make it clear that behaviour can be switched on older editions too, one day in the future. It doesn't *have* to be switched, but I think it's good to have it as an option and re-evaluate it a few months/years down the line when e.g. the crates that showed up in crater were broken by different changes in the language already. cc #25725, #65819, #66145, #84147 , and https://github.com/rust-lang/rust/issues/84133#issuecomment-818005314
2021-04-29Link between std::env::{var, var_os} and std::env::{vars, vars_os}r00ster91-2/+11
2021-04-29Ignore doctests in bootstrapest31-1/+2
On bootstrap the IntoIterator trait is not implemented yet for arrays.
2021-04-28Rollup merge of #84663 - CDirkx:dropguard, r=Mark-SimulacrumJack Huey-24/+4
Remove `DropGuard` in `sys::windows::process` and use `StaticMutex` instead `StaticMutex` is a mutex that when locked provides a guard that unlocks the mutex again when dropped, thus provides the exact same functionality as `DropGuard`. `StaticMutex` is used in more places, and is thus preferred over an ad-hoc construct like `DropGuard`. ````@rustbot```` label: +T-libs-impl
2021-04-28Auto merge of #84615 - a1phyr:clone_from_pathbuf_osstring, r=Mark-Simulacrumbors-3/+39
Override `clone_from` method for PathBuf and OsString This was not the case before because `#[derive(Clone)]` do not do it.
2021-04-28Auto merge of #84650 - a1phyr:simplify_mutex_into_inner, r=m-ou-sebors-19/+2
Simplify `Mutex::into_inner` Thanks to #77147, `Mutex` do not implement `Drop` directly, so the old unsafe implementation of `into_inner` is not relevant anymore.
2021-04-28Remove `DropGuard` in `sys::windows::process` and use `StaticMutex` insteadChristiaan Dirkx-24/+4
2021-04-28Reuse `unix::cmath`Christiaan Dirkx-118/+34
2021-04-28Simplify `Mutex::into_inner`Benoît du Garreau-19/+2
2021-04-28Rollup merge of #84624 - r00ster91:patch-5, r=JohnTitorYuki Okushi-1/+1
Make sentence in env::args_os' docs plain and simple Follow-up to #84551. See https://github.com/rust-lang/rust/pull/84551#discussion_r620728070 on why this makes more sense.
2021-04-28Add a paragraph with possible alternatives on older editionsest31-0/+42
2021-04-27Make sentence in env::args_os' docs plain and simpler00ster-1/+1
2021-04-27Rollup merge of #84521 - CDirkx:hermit-dedup, r=Mark-SimulacrumDylan DPC-92/+3
Reuse modules on `hermit` Reuse the following modules on `hermit`: - `unix::path` (contents identical) - `unsupported::io` (contents identical) - `unsupported::thread_local_key` (contents functionally identical, only changes are the panic error messages) `@rustbot` label: +T-libs-impl
2021-04-27Override `clone_from` method for PathBuf and OsStringBenoît du Garreau-3/+39
2021-04-26Rollup merge of #84551 - r00ster91:patch-4, r=yaahcMara Bos-8/+16
Unify the docs of std::env::{args_os, args} more I noticed that `args_os` was missing some information and I thought it should mention `args` for when you want more safety just like how `args` mentions `args_os` if you don't want it to panic on invalid Unicode.
2021-04-26Point out that behavior might be switched on 2015 and 2018 editions too one dayest31-2/+4
2021-04-25Rollup merge of #84541 - KaiJewson:inline-raw, r=m-ou-seDylan DPC-0/+76
Inline most raw socket, fd and handle conversions Now that file descriptor types on Unix have niches, it is advantageous for user libraries which provide file descriptor wrappers (e.g. `Socket` from socket2) to store a `File` internally instead of a `RawFd`, so that the niche can be taken advantage of. However, doing so will currently result in worse performance as `IntoRawFd`, `FromRawFd` and `AsRawFd` are not inlined. This change adds `#[inline]` to those methods on std types that wrap file descriptors, handles or sockets.
2021-04-25Change wordingr00ster-2/+2
2021-04-25Unify the docs of std::env::{args_os, args} morer00ster-8/+16
2021-04-25Auto merge of #84216 - RalfJung:black-box, r=Mark-Simulacrumbors-0/+1
move core::hint::black_box under its own feature gate The `black_box` function had its own RFC and is tracked separately from the `test` feature at https://github.com/rust-lang/rust/issues/64102. Let's reflect this in the feature gate. To avoid breaking all the benchmarks, libtest's `test::black_box` is a wrapping definition, not a reexport -- this means it is still under the `test` feature gate.
2021-04-25move core::hint::black_box under its own feature gateRalf Jung-0/+1
2021-04-25Auto merge of #84147 - cuviper:array-method-dispatch, r=nikomatsakis,m-ou-sebors-20/+57
Cautiously add IntoIterator for arrays by value Add the attribute described in #84133, `#[rustc_skip_array_during_method_dispatch]`, which effectively hides a trait from method dispatch when the receiver type is an array. Then cherry-pick `IntoIterator for [T; N]` from #65819 and gate it with that attribute. Arrays can now be used as `IntoIterator` normally, but `array.into_iter()` has edition-dependent behavior, returning `slice::Iter` for 2015 and 2018 editions, or `array::IntoIter` for 2021 and later. r? `@nikomatsakis` cc `@LukasKalbertodt` `@rust-lang/libs`
2021-04-25Inline most raw socket, fd and handle conversionsKaiJewson-0/+76
2021-04-24Ignore array IntoIterator tests in bootstrapJosh Stone-2/+4
2021-04-25Auto merge of #84115 - CDirkx:rt, r=m-ou-sebors-262/+175
Rework `init` and `cleanup` This PR reworks the code in `std` that runs before and after `main` and centralizes this code respectively in the functions `init` and `cleanup` in both `sys_common` and `sys`. This makes is easy to see what code is executed during initialization and cleanup on each platform just by looking at e.g. `sys::windows::init`. Full list of changes: - new module `rt` in `sys_common` to contain `init` and `cleanup` and the runtime macros. - `at_exit` and the mechanism to register exit handlers has been completely removed. In practice this was only used for closing sockets on windows and flushing stdout, which have been moved to `cleanup`. - <s>On windows `alloc` and `net` initialization is now done in `init`, this saves a runtime check in every allocation and network use.</s>
2021-04-25Rollup merge of #84179 - CDirkx:dont_send_sync, r=m-ou-seYuki Okushi-27/+30
Explicitly implement `!Send` and `!Sync` for `sys::{Args, Env}` Remove the field `_dont_send_or_sync_me: PhantomData<*mut ()>` in favor of an explicit implementation of `!Send` and `!Sync`.
2021-04-24Reuse `unix::path` and `unsupported::{io, thread_local_key}` on `hermit`Christiaan Dirkx-92/+3
2021-04-24Rollup merge of #84387 - CDirkx:poison, r=m-ou-seYuki Okushi-14/+15
Move `sys_common::poison` to `sync::poison` `sys_common` should not contain publicly exported types, only platform-independent abstractions on top of `sys`, which `sys_common::poison` is not. There is thus no reason for the module to not live under `sync`. Part of #84187.
2021-04-23Explicitly implement `!Send` and `!Sync` for `sys::{Args, Env}`Christiaan Dirkx-27/+30
2021-04-22Rollup merge of #84413 - CDirkx:args_inner_debug, r=m-ou-seDylan DPC-32/+27
Remove `sys::args::Args::inner_debug` and use `Debug` instead This removes the method `sys::args::Args::inner_debug` on all platforms and implements `Debug` for `Args` instead. I believe this creates a more natural API for the different platforms under `sys`: export a type `Args: Debug + Iterator + ...` vs. `Args: Iterator + ...` and with a method `inner_debug`.
2021-04-22Rollup merge of #84402 - CDirkx:rwlock, r=dtolnayDylan DPC-60/+53
Move `sys_common::rwlock::StaticRWLock` etc. to `sys::unix::rwlock` This moves `sys_common::rwlock::StaticRwLock`, `RWLockReadGuard` and `RWLockWriteGuard` to `sys::unix::rwlock`. They are already `#[cfg(unix)]` and don't need to be in `sys_common`.
2021-04-22Remove `Once` from `init`Christiaan Dirkx-6/+10
2021-04-22Document that `init` and `cleanup` are not guaranteed to runChristiaan Dirkx-2/+13
2021-04-22Apply suggestions from reviewChristiaan Dirkx-9/+12
2021-04-22Move most init to `sys::init`Christiaan Dirkx-57/+31
2021-04-22Remove `sys::args::Args::inner_debug` and use `Debug` insteadChristiaan Dirkx-32/+27
2021-04-22Move all cleanup to `sys::cleanup`Christiaan Dirkx-24/+7
2021-04-22Rework `at_exit` to `cleanup`Christiaan Dirkx-196/+134
2021-04-22Move `sys_common::poison` to `sync::poison`Christiaan Dirkx-14/+15
2021-04-21Rollup merge of #84212 - CDirkx:void, r=m-ou-seMara Bos-252/+238
Replace `Void` in `sys` with never type This PR replaces several occurrences in `sys` of the type `enum Void {}` with the Rust never type (`!`). The name `Void` is unfortunate because in other languages (C etc.) it refers to a unit type, not an uninhabited type. Note that the previous stabilization of the never type was reverted, however all uses here are implementation details and not publicly visible.
2021-04-21Rollup merge of #84119 - CDirkx:vxworks, r=m-ou-seMara Bos-222/+88
Move `sys::vxworks` code to `sys::unix` Follow-up to #77666, `sys::vxworks` is almost identical to `sys::unix`, the only differences are the `rand`, `thread_local_dtor`, and `process` implementation. Since `vxworks` is `target_family = unix` anyway, there is no reason for the code not to live inside of `sys::unix` like all the other unix-OSes. https://github.com/rust-lang/rust/blob/e41f378f825488a537b024fc3ed599d9c12fda96/compiler/rustc_target/src/spec/vxworks_base.rs#L12 ``@rustbot`` label: +T-libs-impl