about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-04-03Rollup merge of #109722 - hermitcore:read, r=Mark-SimulacrumMatthias Krüger-7/+24
Implement read_buf for RustHermit In principle, this PR extends rust-lang/rust#108326 for RustyHermit.
2023-04-02Fix typo in std/src/os/fd/owned.rsTaiki Endo-1/+1
2023-03-31Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddleGuillaume Gomez-25/+50
Move `doc(primitive)` future incompat warning to `invalid_doc_attributes` Fixes #88070. It's been a while since this was turned into a "future incompatible lint" so I think we can now turn it into a hard error without problem. r? `@jyn514`
2023-03-30Replace doc(primitive) with rustc_doc_primitiveGuillaume Gomez-25/+50
2023-03-30Refactor glibc time64 support, riscv32 always has 64-bit `time_t`beetrees-14/+36
2023-03-30Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-sebors-53/+41
Partial stabilization of `once_cell` This PR aims to stabilize a portion of the `once_cell` feature: - `core::cell::OnceCell` - `std::cell::OnceCell` (re-export of the above) - `std::sync::OnceLock` This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag. Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue) Future steps for separate PRs: - ~~Add `#[inline]` to many methods~~ #105651 - Update cranelift usage of the `once_cell` crate - Update rust-analyzer usage of the `once_cell` crate - Update error messages discussing once_cell ## To be stabilized API summary ```rust // core::cell (in core/cell/once.rs) pub struct OnceCell<T> { .. } impl<T> OnceCell<T> { pub const fn new() -> OnceCell<T>; pub fn get(&self) -> Option<&T>; pub fn get_mut(&mut self) -> Option<&mut T>; pub fn set(&self, value: T) -> Result<(), T>; pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T; pub fn into_inner(self) -> Option<T>; pub fn take(&mut self) -> Option<T>; } impl<T: Clone> Clone for OnceCell<T>; impl<T: Debug> Debug for OnceCell<T> impl<T> Default for OnceCell<T>; impl<T> From<T> for OnceCell<T>; impl<T: PartialEq> PartialEq for OnceCell<T>; impl<T: Eq> Eq for OnceCell<T>; ``` ```rust // std::sync (in std/sync/once_lock.rs) impl<T> OnceLock<T> { pub const fn new() -> OnceLock<T>; pub fn get(&self) -> Option<&T>; pub fn get_mut(&mut self) -> Option<&mut T>; pub fn set(&self, value: T) -> Result<(), T>; pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T; pub fn into_inner(self) -> Option<T>; pub fn take(&mut self) -> Option<T>; } impl<T: Clone> Clone for OnceLock<T>; impl<T: Debug> Debug for OnceLock<T>; impl<T> Default for OnceLock<T>; impl<#[may_dangle] T> Drop for OnceLock<T>; impl<T> From<T> for OnceLock<T>; impl<T: PartialEq> PartialEq for OnceLock<T> impl<T: Eq> Eq for OnceLock<T>; impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>; unsafe impl<T: Send> Send for OnceLock<T>; unsafe impl<T: Sync + Send> Sync for OnceLock<T>; impl<T: UnwindSafe> UnwindSafe for OnceLock<T>; ``` No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate: ```rust impl<T> OnceCell<T> { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; } impl<T> OnceLock<T> { pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>; } ``` I am new to this process so would appreciate mentorship wherever needed.
2023-03-30Auto merge of #107221 - kleisauke:getentropy-emscripten, r=ChrisDentonbors-2/+3
Use `getentropy()` instead of `/dev/urandom` on Emscripten `/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-29Documentation updates to better share the purpose of OnceCell/OnceLockTrevor Gross-1/+4
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-52/+37
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29Rollup merge of #107387 - joboet:hermit_random, r=ChrisDentonMatthias Krüger-2/+11
Use random `HashMap` keys on Hermit Initializing the keys with random data provided by the libOS avoids HashDOS attacks and similar issues. CC `@stlankes`
2023-03-29Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3bors-48/+4
Support TLS access into dylibs on Windows This allows access to `#[thread_local]` in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it. `convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls. A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms. This fixes https://github.com/rust-lang/rust/issues/84933.
2023-03-29Implement read_buf for RustHermitStefan Lankes-7/+24
In principle, this PR extends rust-lang/rust#108326 for RustyHermit. Signed-off-by: Stefan Lankes <slankes@eonerc.rwth-aachen.de>
2023-03-29std: use `cvt` to handle errors from `read_entropy` on Hermitjoboet-9/+3
2023-03-29Auto merge of #108792 - Amanieu:ohos, r=petrochenkovbors-1/+4
Add OpenHarmony targets - `aarch64-unknown-linux-ohos` - `armv7-unknown-linux-ohos` Compiler team MCP: https://github.com/rust-lang/compiler-team/issues/568
2023-03-29Use #[inline] on Windows for thread local accessJohn Kåre Alsaker-48/+4
2023-03-28Add OpenHarmony targetsAmanieu d'Antras-1/+4
- `aarch64-unknown-linux-ohos` - `armv7-unknown-linux-ohos`
2023-03-28Rollup merge of #91793 - devnexen:anc_data_fbsd, r=ChrisDentonnils-21/+205
socket ancillary data implementation for FreeBSD (from 13 and above). introducing new build config as well.
2023-03-28Add "Platform-specific behavior" heading and link to changes disclaimerJosh Triplett-0/+5
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-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-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-17Modify code style as per commentsNagaChaitanya Vellanki-7/+5
2023-03-16run rustfmt on changesNagaChaitanya Vellanki-1/+1
2023-03-16fallback to lstat when stat fails on WindowsNagaChaitanya Vellanki-1/+13
2023-03-15unequal → not equalgimbles-2/+2
2023-03-15Bump version placeholdersMark Rousskov-2/+2