about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2023-05-01Relax implicit `R: Sized` bound on `BufReader<R>`Maybe Waffle-14/+17
2023-05-01Rollup merge of #111057 - xfix:tcpstream-as-raw-fd-inline, r=m-ou-seMatthias Krüger-0/+69
Make sure the implementation of TcpStream::as_raw_fd is fully inlined Currently the following function: ```rust use std::os::fd::{AsRawFd, RawFd}; use std::net::TcpStream; pub fn as_raw_fd(socket: &TcpStream) -> RawFd { socket.as_raw_fd() } ``` Is optimized to the following: ```asm example::as_raw_fd: push rax call qword ptr [rip + <std::net::tcp::TcpStream as std::sys_common::AsInner<std::sys_common::net::TcpStream>>::as_inner@GOTPCREL] mov rdi, rax call qword ptr [rip + std::sys_common::net::TcpStream::socket@GOTPCREL] mov rdi, rax pop rax jmp qword ptr [rip + _ZN73_$LT$std..sys..unix..net..Socket$u20$as$u20$std..os..fd..raw..AsRawFd$GT$9as_raw_fd17h633bcf7e481df8bbE@GOTPCREL] ``` I think it would make more sense to inline trivial functions used within `TcpStream::AsRawFd`.
2023-05-01Rollup merge of #110987 - infdahai:wasi_clock_time, r=m-ou-seMatthias Krüger-2/+2
update wasi_clock_time_api ref. Closes #110809 >Preview0 corresponded to the import module name wasi_unstable. It was also called snapshot_0 in some places. It was short-lived, and the changes to preview1 were minor, so the focus here is on preview1. we use the `preview1` doc according to the above quote form [WASI legacy Readme](https://github.com/WebAssembly/WASI/blob/main/legacy/README.md) .
2023-05-01Rollup merge of #110093 - beetrees:set-times-32-bit, r=joshtriplettMatthias Krüger-2/+39
Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times` Add support to `set_times` for 64-bit `time_t` on 32-bit glibc Linux platforms which have a 32-bit `time_t`. Split from #109773. Tracking issue: #98245
2023-05-01Rollup merge of #109540 - marcospb19:edit-Path-with_file_name-example, r=m-ou-seMatthias Krüger-5/+11
std docs: edit `PathBuf::set_file_name` example To make explicit that `set_file_name` might replace or remove the extension, not just the file stem. Also edit docs for `Path::with_file_name`, which calls `set_file_name`.
2023-05-01Inline AsRawFd implementationsKonrad Borowski-0/+11
2023-05-01Inline socket function implementationsKonrad Borowski-0/+9
2023-05-01Inline AsInner implementationsKonrad Borowski-0/+49
2023-04-29update wasi_clock_time_api ref.clundro-2/+2
Signed-off-by: clundro <859287553@qq.com>
2023-04-28handle cfg(bootstrap)Pietro Albini-53/+28
2023-04-28replace version placeholdersPietro Albini-44/+44
2023-04-28avoid duplicating TLS state between test std and realstdRalf Jung-17/+22
2023-04-28Auto merge of #110924 - matthiaskrgr:rollup-jvznpq2, r=matthiaskrgrbors-19/+22
Rollup of 6 pull requests Successful merges: - #110766 (More core::fmt::rt cleanup.) - #110873 (Migrate trivially translatable `rustc_parse` diagnostics) - #110904 (rustdoc: rebind bound vars to type-outlives predicates) - #110913 (Add some missing built-in lints) - #110918 (`remove_dir_all`: try deleting the directory even if `FILE_LIST_DIRECTORY` access is denied) - #110920 (Fix unavailable url) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-28Rollup merge of #110898 - m-ou-se:remove-unused-thread-local-key, r=cuviperYuki Okushi-80/+1
Remove unused std::sys_common::thread_local_key::Key Part of https://github.com/rust-lang/rust/issues/110897 This `Key` type seems unused. Let's remove it and see if anything explodes. :)
2023-04-28Rollup merge of #110620 - Nilstrieb:document-the-undocumented, r=thomccYuki Okushi-2/+20
Document `const {}` syntax for `std::thread_local`. It exists and is pretty cool. More people should use it. It was added in #83416 and stabilized in #91355 with the tracking issue #84223.
2023-04-28remove_dir_all: delete directory with fewer permsChris Denton-19/+22
If opening a directory with `FILE_LIST_DIRECTORY` access fails then we should try opening without requesting that access. We may still be able to delete it if it's empty or a link.
2023-04-27Rollup merge of #106599 - MikailBag:patch-1, r=jyn514Matthias Krüger-4/+4
Change memory ordering in System wrapper example Currently, the `SeqCst` ordering is used, which seems unnecessary: + Even `Relaxed` ordering guarantees that all updates are atomic and are executed in total order + User code only reads atomic for monitoring purposes, no "happens-before" relationships with actual allocations and deallocations are needed for this If argumentation above is correct, I propose changing ordering to `Relaxed` to clarify that no synchronization is required here, and improve performance (if somebody copy-pastes this example into their code).
2023-04-27Rollup merge of #106456 - kadiwa4:std-prelude-comment, r=jyn514Matthias Krüger-4/+4
Correct `std::prelude` comment (Read the changed file first for context.) First, `alloc` has no prelude. Second, the docs for `v1` don't matter since the [prelude module] already has all the doc links. The `rust_2021` module for instance also doesnt have a convenient doc page. However as I understand glob imports still cant be used because the items dont have the same stabilisation versions. [prelude module]: https://doc.rust-lang.org/std/prelude/index.html
2023-04-27Rollup merge of #105745 - philpax:patch-1, r=jyn514Matthias Krüger-0/+5
docs(std): clarify remove_dir_all errors When using `remove_dir_all`, I assumed that the function was idempotent and that I could always call it to remove a directory if it existed. That's not the case and it bit me in production, so I figured I'd submit this to clarify the docs.
2023-04-27Document `const {}` syntax for `std::thread_local`.Nilstrieb-2/+20
It exists and is pretty cool. More people should use it.
2023-04-27correct `std::prelude` commentKaDiWa-4/+4
2023-04-27Update test.Mara Bos-19/+1
2023-04-27Remove unused std::sys_common::thread_local_key::Key.Mara Bos-61/+0
2023-04-27Remove all in target_thread_local cfgAyush Singh-1/+1
I think it was left there by mistake after previous refactoring. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-04-27std: use `LazyLock` to lazily resolve backtracesjoboet-54/+35
2023-04-27Auto merge of #110562 - ComputerDruid:riscv, r=tmandrybors-1/+7
Add definitions for riscv64gc-unknown-fuchsia To compile, also requires a libc update with https://github.com/rust-lang/libc/pull/3204
2023-04-27docs(std): clarify `remove_dir_all` errorsPhilpax-0/+5
2023-04-26Auto merge of #110861 - m-ou-se:thread-local-restructure, r=workingjubileebors-311/+283
Restructure and rename std thread_local internals to make it less of a maze Every time I try to work on std's thread local internals, it feels like I'm trying to navigate a confusing maze made of macros, deeply nested modules, and types with multiple names/aliases. Time to clean it up a bit. This PR: - Exports `Key` with its own name (`Key`), instead of `__LocalKeyInner` - Uses `pub macro` to put `__thread_local_inner` into a (unstable, hidden) module, removing `#[macro_export]`, removing it from the crate root. - Removes the `__` from `__thread_local_inner`. - Removes a few unnecessary `allow_internal_unstable` features from the macros - Removes the `libstd_thread_internals` feature. (Merged with `thread_local_internals`.) - And removes it from the unstable book - Gets rid of the deeply nested modules for the `Key` definitions (`mod fast` / `mod os` / `mod statik`). - Turns a `#[cfg]` mess into a single `cfg_if`, now that there's no `#[macro_export]` anymore that breaks with `cfg_if`. - Simplifies the `cfg_if` conditions to not repeat the conditions. - Removes useless `normalize-stderr-test`, which were left over from when the `Key` types had different names on different platforms. - Removes a seemingly unnecessary `realstd` re-export on `cfg(test)`. This PR changes nothing about the thread local implementation. That's for a later PR. (Which should hopefully be easier once all this stuff is a bit cleaned up.)
2023-04-26Restructure and rename thread local things in std.Mara Bos-311/+283
2023-04-26Rollup merge of #110419 - jsoref:spelling-library, r=jyn514Matthias Krüger-19/+20
Spelling library Split per https://github.com/rust-lang/rust/pull/110392 I can squash once people are happy w/ the changes. It's really uncommon for large sets of changes to be perfectly acceptable w/o at least some changes. I probably won't have time to respond until tomorrow or the next day
2023-04-26Rollup merge of #110587 - tomaka:fix-109727, r=jyn514jyn-2/+7
Fix `std` compilation error for wasi+atomics Fix https://github.com/rust-lang/rust/issues/109727 It seems that the `unsupported/once.rs` module isn't meant to exist at the same time as the `futex` module, as they have conflicting definitions. I've solved this by defining the `once` module only if `not(target_feature = "atomics")`. The `wasm32-unknown-unknown` target [similarly only defines the `once` module if `not(target_feature = "atomics")`](https://github.com/tomaka/rust/blob/01c4f319276da912dd2be768ae0ce9857ad6bb63/library/std/src/sys/wasm/mod.rs#L69-L70). As show in [this block of code](https://github.com/tomaka/rust/blob/01c4f319276da912dd2be768ae0ce9857ad6bb63/library/std/src/sys_common/once/mod.rs#L10-L34), the `sys::once` module doesn't need to exist if `all(target_arch = "wasm32", target_feature = "atomics")`.
2023-04-26Rollup merge of #110266 - tgross35:try-exists-wording, r=jyn514jyn-6/+9
Update documentation wording on path 'try_exists' functions Just eliminate the quadruple negation in `doesn't silently ignore errors unrelated to ... not existing.`
2023-04-26rewrite: line_long_tail_not_flushed descriptionJosh Soref-3/+4
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-26rewrite: long_line_flushed descriptionJosh Soref-3/+3
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-26Spelling library/Josh Soref-13/+13
* advance * aligned * borrowed * calculate * debugable * debuggable * declarations * desugaring * documentation * enclave * ignorable * initialized * iterator * kaboom * monomorphization * nonexistent * optimizer * panicking * process * reentrant * rustonomicon * the * uninitialized Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-25Add definitions for riscv64gc-unknown-fuchsiaDan Johnson-1/+7
2023-04-25Add FreeBSD cpuset support to std::thread::available_concurrencyThomas Hurst-0/+19
Use libc::cpuset_getaffinity to determine the CPUs available to the current process. The existing sysconf and sysctl paths are left as fallback.
2023-04-25Rollup merge of #110782 - matthiaskrgr:revert_panic_oom, r=AmanieuMatthias Krüger-30/+94
Revert panic oom This temporarily reverts https://github.com/rust-lang/rust/pull/109507 until https://github.com/rust-lang/rust/issues/110771 is addressed r? `@Amanieu`
2023-04-24Auto merge of #106152 - SUPERCILEX:lazycell, r=Amanieubors-1/+37
Add LazyCell::into_inner This enables uses cases that need to extract the evaluated value and do something owned with it.
2023-04-25Revert "Report allocation errors as panics"Matthias Krüger-28/+18
This reverts commit c9a6e41026d7aa27d897fb83e995447719753076.
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-2/+76
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-23Auto merge of #110655 - ChrisDenton:read-to-end, r=joshtriplettbors-24/+43
Limit read size in `File::read_to_end` loop Fixes #110650. Windows file reads have perf overhead that's proportional to the buffer size. When we have a reasonable expectation that we know the file size, we can set a reasonable upper bound for the size of the buffer in one read call.
2023-04-22Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors-94/+30
Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
2023-04-21Limit read size in `File::read_to_end` loopChris Denton-24/+43
This works around performance issues on Windows by limiting reads the size of reads when the expected size is known.
2023-04-21Rollup merge of #110633 - scottmcm:more-take, r=thomccDylan DPC-5/+5
More `mem::take` in `library` A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-20More `mem::take` in `library`Scott McMurray-5/+5
A bunch of places were using `replace(…, &mut [])`, but that can just be `take`.
2023-04-20Specialize some `io::Read` and `io::Write` methods for `VecDeque<u8>` and ↵Benoît du Garreau-0/+54
`&[u8]`
2023-04-20Implement `BufRead` for `VecDeque<u8>`Benoît du Garreau-0/+18
2023-04-20Fix `std` compilation error for wasi+atomicsPierre Krieger-2/+7
2023-04-19Auto merge of #106704 - ecnelises:big_archive, r=bjorn3bors-3/+3
Support AIX-style archive type Reading facility of AIX big archive has been supported by `object` since 0.30.0. Writing facility of AIX big archive has already been supported by `ar_archive_writer`, but we need to bump the version to support the new archive type enum.