about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
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.`
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-0/+6
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-29/+93
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-27/+17
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-93/+29
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 #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obkbors-6/+3
Rm const traits in libcore See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework) * [x] Bless ui tests * [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-19std: make `Debug` representations of `[Lazy, Once]*[Cell, Lock]` consistent ↵joboet-20/+12
with `Mutex` and `RwLock` `Mutex` prints `<locked>` as a field value when its inner value cannot be accessed, but the lazy types print a fixed string like "`OnceCell(Uninit)`". This could cause confusion if the inner type is a unit type named `Uninit` and does not respect the pretty-printing flag. With this change, the format message is now "`OnceCell(<uninit>)`", consistent with `Mutex`.
2023-04-16Windows: map a few more error codes to ErrorKindChris Denton-3/+6
NotFound errors: * `ERROR_INVALID_DRIVE`: The system cannot find the drive specified * `ERROR_BAD_NETPATH`: The network path was not found * `ERROR_BAD_NET_NAME`: The network name cannot be found. InvalidFilename: * `ERROR_BAD_PATHNAME`: The specified path is invalid.
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-76/+2
2023-04-16Report allocation errors as panicsAmanieu d'Antras-17/+27
2023-04-16rm const traits in libcoreDeadbeef-6/+3
2023-04-14edit docs of `PathBuf::set_file_name`João M. Bezerra-5/+11
to show this method might replace or remove the extension, not just the file stem also edit docs of `Path::with_file_name` because it calls `PathBuf::set_file_name`