about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-03-17reviewGus Caplan-3/+3
2023-03-17move default backtrace setting to sysGus Caplan-2/+10
2023-03-18Stabilise `unix_socket_abstract`John Millikin-20/+15
Fixes https://github.com/rust-lang/rust/issues/85410
2023-03-18Rollup merge of #109235 - chaitanyav:master, r=ChrisDentonMatthias Krüger-1/+11
fallback to lstat when stat fails on Windows Fixes #109106 ````@ChrisDenton```` please let me know if this is the expected behavior for stat on windows
2023-03-17Remove irrelevant docs on error kindsJubilee Young-10/+4
2023-03-17Auto merge of #108862 - Mark-Simulacrum:bootstrap-bump, r=pietroalbinibors-2/+2
Bump bootstrap compiler to 1.69 beta r? `@pietroalbini`
2023-03-17Add Command environment variable inheritance docsschneems-15/+61
The interaction between the environment variable methods can be confusing. Specifically `env_clear` and `remove_env` have a side effects not mentioned: they disable inheriting environment variables from the parent process. I wanted to fully document this behavior as well as explain relevant edge cases in each of the `Command` env methods. This is further confused by the return of `get_envs` which will return key/None if `remove_env` has been used, but an empty iterator if `env_clear` has been called. Or a non-empty iterator if `env_clear` was called and later explicit mappings are added. Currently there is no way (that I'm able to find) of observing whether or not the internal `env_clear=true` been toggled on the `Command` struct via its public API. Ultimately environment variable mappings can be in one of several states: - Explicitly set value (via `envs` / `env`) will take precedence over parent mapping - Not explicitly set, will inherit mapping from parent - Explicitly removed via `remove_env`, this single mapping will not inherit from parent - Implicitly removed via `env_clear`, no mappings will inherit from parent I tried to represent this in the relevant sections of the docs. This is my second ever doc PR (whoop!). I'm happy to take specific or general doc feedback. Also happy to explain the logic behind any changes or additions I made.
2023-03-17Modify code style as per commentsNagaChaitanya Vellanki-7/+5
2023-03-17Update mod.rsSean Linsley-2/+2
2023-03-17fix typo in documentation for std::fs::PermissionsMarc R. Schoolderman-1/+1
2023-03-16run rustfmt on changesNagaChaitanya Vellanki-1/+1
2023-03-16fallback to lstat when stat fails on WindowsNagaChaitanya Vellanki-1/+13
2023-03-16Clarify that RUST_MIN_STACK is internally cachedSean Linsley-1/+2
For larger applications it's important that users set `RUST_MIN_STACK` at the start of their program because `min_stack` caches the value. Not doing so can lead to their `env::set_var` call surprisingly not having any effect.
2023-03-15unequal → not equalgimbles-2/+2
2023-03-15Bump version placeholdersMark Rousskov-2/+2
2023-03-14std: leak remaining messages in bounded channel if message destructor panicsjoboet-66/+42
2023-03-14Use getentropy() instead of /dev/urandom on EmscriptenKleis Auke Wolthuizen-2/+3
`/dev/urandom` is usually available on Emscripten, except when using the special `NODERAWFS` filesystem backend, which replaces all normal filesystem access with direct Node.js operations. Since this filesystem backend directly access the filesystem on the OS, it is not recommended to depend on `/dev/urandom`, especially when trying to run the Wasm binary on OSes that are not Unix-based. This can be considered a non-functional change, since Emscripten implements `/dev/urandom` in the same way as `getentropy()` when not linking with `-sNODERAWFS`.
2023-03-13Rollup merge of #108507 - hermitcore:new, r=m-ou-seMatthias Krüger-4/+3
use `as_ptr` to determine the address of atomics The PR #107736 renamed atomic `as_mut_ptr` to `as_ptr`. Consequently, the futex implementation of the tier-3 platform `RutyHermit` has to use this new interface. In addition, this PR removes also an unused import.
2023-03-13Rollup merge of #108419 - tgross35:atomic-as-ptr, r=m-ou-seMatthias Krüger-1/+0
Stabilize `atomic_as_ptr` Fixes #66893 This stabilizes the `as_ptr` methods for atomics. The stabilization feature gate used here is `atomic_as_ptr` which supersedes `atomic_mut_ptr` to match the change in https://github.com/rust-lang/rust/pull/107736. This needs FCP. New stable API: ```rust impl AtomicBool { pub const fn as_ptr(&self) -> *mut bool; } impl AtomicI32 { pub const fn as_ptr(&self) -> *mut i32; } // Includes all other atomic types impl<T> AtomicPtr<T> { pub const fn as_ptr(&self) -> *mut *mut T; } ``` r? libs-api ``@rustbot`` label +needs-fcp
2023-03-11read_buf_exact: on error, all read bytes are appended to the bufferTomasz Miąsko-2/+16
Guarantee that when `read_buf_exact` returns, all bytes read will be appended to the buffer. Including the case when the operations fails. The motivating use case are operations on a non-blocking reader. When `read_buf_exact` fails with `ErrorKind::WouldBlock` error, the operation can be resumed at a later time.
2023-03-11Rollup merge of #108927 - Ayush1325:pal-cleanup, r=workingjubileeMatthias Krüger-603/+719
Move __thread_local_inner to sys Move `__thread_local_inner` macro in `crate::thread::local` to `crate::sys`. Initially, I was thinking about removing this macro completely, but I could not find a way to create the generic statics without macros, so in the end, I just moved to code around. This probably will need a rebase once https://github.com/rust-lang/rust/pull/108917 is merged r? ``@workingjubilee``
2023-03-10Rollup merge of #105962 - zertosh:stabilize_path_as_mut_os_str, r=dtolnayMatthias Krüger-4/+2
Stabilize path_as_mut_os_str Closes #105021 r? ```@dtolnay```
2023-03-10Moved thread_local implementation to sys::commonAyush Singh-724/+718
This allows removing all the platform-dependent code from `library/std/src/thread/local.rs` and `library/std/src/thread/mod.rs` Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-03-10Split __thread_local_inner macroAyush Singh-194/+316
Split the __thread_local_inner macro to make it more readable. Also move everything to crate::sys::common::thread_local. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-03-10Move __thread_local_inner to sysAyush Singh-194/+194
Move __thread_local_inner macro in crate::thread::local to crate::sys. Currently, the tidy check does not fail for `library/std/src/thread/local.rs` even though it contains platform specific code. This is beacause target_family did not exist at the time the tidy checks were written [1]. [1]: https://github.com/rust-lang/rust/pull/105861#discussion_r1125841678 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-03-08rand: freebsd update, using getrandom.David CARLIER-4/+18
supported since the 12th release, while 11.4 is EOL since 2021.
2023-03-07Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, ↵bors-0/+93
r=pnkfelix,m-ou-se,scottmcm Add `round_ties_even` to `f32` and `f64` Tracking issue: #96710 Redux of #82273. See also #55107 Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this. Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`). Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight. Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
2023-03-06Implement read_buf for a few more typesTomasz Miąsko-31/+250
Implement read_buf for TcpStream, Stdin, StdinLock, ChildStdout, ChildStderr (and internally for AnonPipe, Handle, Socket), so that it skips buffer initialization. The other provided methods like read_to_string and read_to_end are implemented in terms of read_buf and so benefit from the optimization as well. This commit also implements read_vectored and is_read_vectored where applicable.
2023-03-04Auto merge of #89518 - a1phyr:unix_file_vectored_at, r=workingjubileebors-3/+276
Add vectored positioned I/O on Unix Add methods for vectored I/O with an offset on `File` for `unix` under `#![feature(unix_file_vectored_at)]`. The new methods are wrappers around `preadv` and `pwritev`. Tracking issue: #89517
2023-03-03Use weak linkage for `preadv` and `pwritev` on MacOS and iOSBenoît du Garreau-8/+18
2023-03-03Update library/std/src/io/mod.rsMichal Nazarewicz-1/+1
Co-authored-by: Jacob Lifshay <programmerjake@gmail.com>
2023-03-03Match unmatched backticks in library/est31-5/+5
2023-03-02Make std tests pass on newer AndroidPeter Collingbourne-0/+20
Newer versions of Android forbid the creation of hardlinks as well as Unix domain sockets in the /data filesystem via SELinux rules, which causes several tests depending on this behavior to fail. So let's skip these tests on Android with an #[ignore] directive.
2023-03-02Add basic testsBenoît du Garreau-0/+61
2023-03-02Take shared references as parameterBenoît du Garreau-12/+4
2023-03-02Use weak linkage on AndroidBenoît du Garreau-4/+96
2023-03-02Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubileebors-49/+427
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr` ⚠️ Backtraces on QNX require https://github.com/rust-lang/backtrace-rs/pull/507 which is not yet merged! (But everything else works without these changes) ⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
2023-03-01Update library/std/src/os/nto/mod.rsFlorian Bartels-1/+1
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2023-03-01Update library/std/src/io/mod.rsMichal Nazarewicz-3/+3
Co-authored-by: Andrew Gallant <jamslam@gmail.com>
2023-03-01Rollup merge of #108531 - Coca162:rustdoc-repeat-const-array, r=thomccMatthias Krüger-2/+4
rustdoc: Show that repeated expression arrays can be made with constant values The [rust reference](https://doc.rust-lang.org/reference/expressions/array-expr.html) currently says that repeated values for arrays can be constant or `Copy` > repeat operand is [Copy](https://doc.rust-lang.org/reference/special-types-and-traits.html#copy) or that it must be a [path](https://doc.rust-lang.org/reference/expressions/path-expr.html) to a constant item This updates the rust documentation on primitive arrays to reflect what the rust reference says (and also compiler suggestions if you do not use a `const` item)
2023-02-28Retry to spawn/fork up to 3 times when it failed because of an interruptionFlorian Bartels-2/+64
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-48/+364
Co-authored-by: gh-tr <troach@qnx.com>
2023-02-27Rollup merge of #107110 - strega-nil:mbtwc-wctmb, r=ChrisDentonMatthias Krüger-29/+78
[stdio][windows] Use MBTWC and WCTMB `MultiByteToWideChar` and `WideCharToMultiByte` are extremely well optimized, and therefore should probably be used when we know we can (specifically in the Windows stdio stuff). Fixes #107092
2023-02-27Clarify that Copy is a trait in array docsCoca162-1/+1
2023-02-27Update docs to show [expr; N] can repeat const exprCoca162-2/+4
2023-02-27Add vectored positioned I/O on UnixBenoît du Garreau-3/+121
2023-02-27use `as_ptr` to determine the address of atomicsStefan Lankes-3/+3
2023-02-26remove unused importsStefan Lankes-1/+0
2023-02-26Move IpAddr and SocketAddr to coreLinus Färnstrand-4468/+28
2023-02-26std: disconnect senders before discarding messagesjoboet-4/+5