about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-05-05Sort windows_sys.lst alphabeticallyChris Denton-614/+617
2023-05-05Use new bindingsChris Denton-53/+70
2023-05-05Generate windows-sys bindingsChris Denton-3045/+7016
2023-05-05feat: merge functionality of `io::Sink` into `io::Empty`Vidhan Bhatt-26/+87
2023-05-05Rollup merge of #103056 - beetrees:timespec-bug-fix, r=thomccDylan DPC-24/+35
Fix `checked_{add,sub}_duration` incorrectly returning `None` when `other` has more than `i64::MAX` seconds Use `checked_{add,sub}_unsigned` in `checked_{add,sub}_duration` so that the correct result is returned when adding/subtracting durations with more than `i64::MAX` seconds.
2023-05-05Rollup merge of #110946 - RalfJung:tls-realstd, r=m-ou-seYuki Okushi-17/+22
avoid duplicating TLS state between test std and realstd This basically re-lands https://github.com/rust-lang/rust/pull/100201 and https://github.com/rust-lang/rust/pull/106638, which got reverted by https://github.com/rust-lang/rust/pull/110861. This works around 2 Miri limitations: - Miri doesn't support the magic linker section that our Windows TLS support relies on, and instead knows where in std to find the symbol that stores the thread callback. - For macOS, Miri only supports at most one destructor to be registered per thread. The 2nd would not be very hard to fix (though the intended destructor order is unclear); the first would be a lot of work to fix. Neither of these is a problem for regular Rust code, but in the std test suite we have essentially 2 copies of the std code and then these both become issues. To avoid that we have the std test crate import the TLS code from the real std instead of having its own copy. r? ``````@m-ou-se``````
2023-05-04Rollup merge of #111009 - scottmcm:ascii-char, r=BurntSushiMatthias Krüger-0/+3
Add `ascii::Char` (ACP#179) ACP second: https://github.com/rust-lang/libs-team/issues/179#issuecomment-1527900570 New tracking issue: https://github.com/rust-lang/rust/issues/110998 For now this is an `enum` as `@kupiakos` [suggested](https://github.com/rust-lang/libs-team/issues/179#issuecomment-1527959724), with the variants under a different feature flag. There's lots more things that could be added here, and place for further doc updates, but this seems like a plausible starting point PR. I've gone through and put an `as_ascii` next to every `is_ascii`: on `u8`, `char`, `[u8]`, and `str`. As a demonstration, made a commit updating some formatting code to use this: https://github.com/scottmcm/rust/commit/ascii-char-in-fmt (I don't want to include that in this PR, though, because that brings in perf questions that don't exist if this is just adding new unstable APIs.)
2023-05-03Add the basic `ascii::Char` typeScott McMurray-0/+3
2023-05-03Rollup merge of #105695 - joboet:remove_generic_parker, r=m-ou-seManish Goregaokar-129/+17
Replace generic thread parker with explicit no-op parker With #98391 merged, all platforms supporting threads now have their own parking implementations. Therefore, the generic implementation can be removed. On the remaining platforms (really just WASM without atomics), parking is not supported, so calls to `thread::park` now return instantly, which is [allowed by their API](https://doc.rust-lang.org/nightly/std/thread/fn.park.html). This is a change in behaviour, as spurious wakeups do not currently occur since all platforms guard against them. It is invalid to depend on this, but I'm still going to tag this as libs-api for confirmation. ````@rustbot```` label +T-libs +T-libs-api +A-atomic r? rust-lang/libs
2023-05-03Rollup merge of #97594 - WaffleLapkin:array_tuple_conv, r=ChrisDentonManish Goregaokar-0/+20
Implement tuple<->array convertions via `From` This PR adds the following impls that convert between homogeneous tuples and arrays of the corresponding lengths: ```rust impl<T> From<[T; 1]> for (T,) { ... } impl<T> From<[T; 2]> for (T, T) { ... } /* ... */ impl<T> From<[T; 12]> for (T, T, T, T, T, T, T, T, T, T, T, T) { ... } impl<T> From<(T,)> for [T; 1] { ... } impl<T> From<(T, T)> for [T; 2] { ... } /* ... */ impl<T> From<(T, T, T, T, T, T, T, T, T, T, T, T)> for [T; 12] { ... } ``` IMO these are quite uncontroversial but note that they are, just like any other trait impls, insta-stable.
2023-05-03Mention array<->tuple convs in docsMaybe Waffle-0/+20
2023-05-03Fix MXCSR configuration dependent timingRaoul Strackx-1/+5
Some data-independent timing vector instructions may have subtle data-dependent timing due to MXCSR configuration; dependent on (potentially secret) data instruction retirement may be delayed by one cycle.
2023-05-03Remove unnecessary Send boundGil Shoshan-3/+3
2023-05-03Use `from_wide_to_user_path` in `read_link`Chris Denton-4/+7
2023-05-03Correctly convert an NT path to a Win32 pathChris Denton-12/+21
This can be done by simply changing the `\??\` prefix to `\\?\` and then attempting to convert to a user path. Currently it simply strips off the prefix which could lead to the wrong path being returned (e.g. if it's not a drive path or if the path contains trailing spaces, etc).
2023-05-02Rollup merge of #110895 - Ayush1325:thread-local-fix, r=thomccDylan DPC-1/+1
Remove `all` in target_thread_local cfg I think it was left there by mistake after the previous refactoring. I just came across it while rebasing to master.
2023-05-01Relax implicit `W: Sized` bound on `LineWriter<W>`Maybe Waffle-27/+29
2023-05-01Relax implicit `W: Sized` bound on `BufWriter<W>`Maybe Waffle-70/+72
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/+25
2023-04-27Auto merge of #110562 - ComputerDruid:riscv, r=tmandrybors-0/+6
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.`