about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-03-28Document the heuristics IsTerminal uses on WindowsJosh Triplett-0/+4
2023-03-27socket ancillary data implementation for FreeBSD (from 13 and above).David CARLIER-21/+205
introducing new build config as well.
2023-03-27Document that SystemTime does not count leap secondsIan Jackson-0/+20
Fixes #77994
2023-03-27Add note about clone-and-hack to the two UNIX_EPOCH definitionsIan Jackson-0/+6
I edited one of these and looked at the formatted docs for the other. This confused me for a while; I suspected a build system bug. I don't see an easy and neat way to unify these. So let's just document it instead.
2023-03-27Rollup merge of #102742 - bjorn3:cleanup_rust_start_panic, r=ChrisDentonMatthias Krüger-10/+5
Remove unnecessary raw pointer in __rust_start_panic arg It is no longer necessary as __rust_start_panic switched to the Rust abi.
2023-03-27Rollup merge of #98651 - mattfbacon:master, r=ChrisDentonMatthias Krüger-1/+1
Follow C-RW-VALUE in std::io::Cursor example rustc-dev-guide says to do this: r? ``@steveklabnik``
2023-03-27Rollup merge of #97506 - JohnTitor:stabilize-nonnull-slice-from-raw-parts, ↵Matthias Krüger-1/+0
r=m-ou-se,the8472 Stabilize `nonnull_slice_from_raw_parts` FCP is done: https://github.com/rust-lang/rust/issues/71941#issuecomment-1100910416 Note that this doesn't const-stabilize `NonNull::slice_from_raw_parts` as `slice_from_raw_parts_mut` isn't const-stabilized yet. Given #67456 and #57349, it's not likely available soon, meanwhile, stabilizing only the feature makes some sense, I think. Closes #71941
2023-03-26Remove unnecessary raw pointer in __rust_start_panic argbjorn3-10/+5
It is no longer necessary as __rust_start_panic switched to the Rust abi.
2023-03-24Rollup merge of #109406 - WaffleLapkin:🥛, r=cuviperMatthias Krüger-7/+0
Remove outdated comments What the title said
2023-03-24Rollup merge of #109368 - hermitcore:typo, r=cuviperMatthias Krüger-1/+1
fix typo in the creation of OpenOption for RustyHermit Due to this typo we have to build a workaround for issue hermitcore/libhermit-rs#191. RustyHermit is a tier 3 platform and backward compatibility does not have to be guaranteed.
2023-03-24Rollup merge of #109142 - the8472:mutex-block-docs, r=cuviperMatthias Krüger-7/+17
Add block-based mutex unlocking example This modifies the existing example in the Mutex docs to show both `drop()` and block based early unlocking. Alternative to #81872, which is getting closed.
2023-03-23Rollup merge of #106964 - ↵Matthias Krüger-2/+10
workingjubilee:crouching-ioerror-hidden-documentation, r=ChrisDenton Clarify `Error::last_os_error` can be weird Fundamentally, querying the OS for error codes is a process that is deeply subject to the whims of chance and fortune. We can account for OS, but not for every combination of platform APIs. A compiled binary may not recognize new errors introduced years later. We should clarify a few especially odd situations, and what they mean: We can effectively promise nothing... if you ask for Rust to decode errors where none have occurred. This allows removing mention of ErrorKind::Uncategorized. That error variant is hidden deliberately, so we should not explicitly mention it. This fixes #106937. Since you had an opinion also: Does this solution seem acceptable? r? ``@ChrisDenton``
2023-03-22Check the presence of linkat() on Solaris (not available in version 10, ↵Daniel Laügt-5/+6
available in version 11)
2023-03-21Rollup merge of #108164 - joboet:discard_messages_mpmc_array, r=AmanieuMatthias Krüger-26/+98
Drop all messages in bounded channel when destroying the last receiver Fixes #107466 by splitting the `disconnect` function for receivers/transmitters and dropping all messages in `disconnect_receivers` like the unbounded channel does. Since all receivers must be dropped before the channel is, the messages will already be discarded at that point, so the `Drop` implementation for the channel can be removed. ``@rustbot`` label +T-libs +A-concurrency
2023-03-21Rollup merge of #96391 - ChrisDenton:command-non-verbatim, r=joshtriplettMatthias Krüger-38/+62
Windows: make `Command` prefer non-verbatim paths When spawning Commands, the path we use can end up being queried using `env::current_exe` (or the equivalent in other languages). Not all applications handle these paths properly therefore we should have a stronger preference for non-verbatim paths when spawning processes.
2023-03-21Rollup merge of #108326 - tmiasko:read-buf, r=thomccnils-31/+250
Implement read_buf for a few more types 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-21Auto merge of #108262 - ChrisDenton:libntdll, r=Mark-Simulacrumbors-47/+40
Distribute libntdll.a with windows-gnu toolchains This allows the OS loader to load essential functions (e.g. read/write file) at load time instead of lazily doing so at runtime. r? libs
2023-03-20Remove outdated commentsMaybe Waffle-7/+0
2023-03-20Apply suggestions from code reviewthe8472-3/+3
Co-authored-by: Josh Stone <cuviper@gmail.com>
2023-03-20Add block-based mutex unlocking exampleThe 8472-7/+17
2023-03-19fix typo in the creation of OpenOptionStefan Lankes-1/+1
Due to this typo we have to build a workaround for issue hermitcore/libhermit-rs#191. RustyHermit is a tier 3 platform and backward compatibility does not have to be guaranteed.
2023-03-19Rollup merge of #109022 - tmiasko:read-buf-exact, r=dtolnayDylan DPC-2/+16
read_buf_exact: on error, all read bytes are appended to the buffer 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-19Rollup merge of #108798 - devsnek:panic-pal-exception, r=workingjubileeDylan DPC-2/+10
move default backtrace setting to sys another PAL exception. moves the default backtrace setting to sys.
2023-03-18Rollup merge of #109288 - jmillikin:linux-abstract-socket-addr, r=joshtriplettMatthias Krüger-20/+15
Stabilise `unix_socket_abstract` Fixes https://github.com/rust-lang/rust/issues/85410
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-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`?