about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-11-27update cfgsBoxy-12/+2
2024-11-27Implement code reviewSebastian Urban-2/+1
2024-11-27replace placeholder versionBoxy-7/+7
2024-11-27Rollup merge of #133449 - joboet:io_const_error, r=tgross35Matthias Krüger-266/+250
std: expose `const_io_error!` as `const_error!` ACP: https://github.com/rust-lang/libs-team/issues/205 Tracking issue: https://github.com/rust-lang/rust/issues/133448 Probably best reviewed commit-by-commit, the first one does the API change, the second does the mass-rename.
2024-11-26Auto merge of #133505 - compiler-errors:rollup-xjp8hdi, r=compiler-errorsbors-1/+4
Rollup of 12 pull requests Successful merges: - #133042 (btree: add `{Entry,VacantEntry}::insert_entry`) - #133070 (Lexer tweaks) - #133136 (Support ranges in `<[T]>::get_many_mut()`) - #133140 (Inline ExprPrecedence::order into Expr::precedence) - #133155 (Yet more `rustc_mir_dataflow` cleanups) - #133282 (Shorten the `MaybeUninit` `Debug` implementation) - #133326 (Remove the `DefinitelyInitializedPlaces` analysis.) - #133362 (No need to re-sort existential preds in relate impl) - #133367 (Simplify array length mismatch error reporting (to not try to turn consts into target usizes)) - #133394 (Bail on more errors in dyn ty lowering) - #133410 (target check_consistency: ensure target feature string makes some basic sense) - #133435 (miri: disable test_downgrade_observe test on macOS) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-26chore: Improve doc commentsPiotr Osiewicz-2/+3
2024-11-26std: update internal uses of `io::const_error!`joboet-246/+213
2024-11-26Rollup merge of #133435 - RalfJung:test_downgrade_observe, r=tgross35Michael Goulet-1/+4
miri: disable test_downgrade_observe test on macOS Due to https://github.com/rust-lang/rust/issues/121950, this test can fail on Miri. The test is also quite slow on Miri (taking more than 30s) due to the high iteration count (a total of 2000), so let's reduce that a little. Fixes https://github.com/rust-lang/rust/issues/133421
2024-11-26Rollup merge of #133464 - RalfJung:whitespace-panic, r=joboetGuillaume Gomez-7/+7
std::thread: avoid leading whitespace in some panic messages This: ``` panic!( "use of std::thread::current() is not possible after the thread's local data has been destroyed" ) ``` will print a newline followed by a bunch of spaces, since the entire string literal is interpreted literally. I think the intention was to print the message without the newline and the spaces, so let's add some `\` to make that happen. r? ``@joboet``
2024-11-26Rollup merge of #133419 - CromFr:add-path-strip_prefix-test-example, r=AmanieuGuillaume Gomez-0/+1
Added a doc test for std::path::strip_prefix I was about 90% sure `Path::new("/test/haha/foo.txt").strip_prefix("/te")` would return an Err, but I couldn't find an example to confirm this behaviour. This should be an easy merge :)
2024-11-26Add missing code examples on `LocalKey`Guillaume Gomez-2/+28
2024-11-26thread::available_parallelism for wasm32-wasip1-threadsSebastian Urban-3/+14
The target has limited POSIX support and provides the sysconf function which allows querying the number of available CPUs.
2024-11-26Refactor ReadDir into a state machinePiotr Osiewicz-70/+101
2024-11-25Run TLS destructors for wasm32-wasip1-threadsSebastian Urban-0/+74
The target has support for pthreads and allows registration of TLS destructors.
2024-11-25std::thread: avoid leading whitespace in some panic messagesRalf Jung-7/+7
2024-11-25std: expose `const_io_error!` as `const_error!`joboet-20/+37
ACP: rust-lang/libs-team#205 Tracking issue: #133448
2024-11-25miri: disable test_downgrade_observe test on macOSRalf Jung-1/+4
2024-11-25Rollup merge of #133298 - n0toose:remove-dir-all-but-not-paths, r=Noratrieb许杰友 Jieyou Xu (Joe)-1/+2
Mention that std::fs::remove_dir_all fails on files This is explicitly mentioned for std::fs::remove_file. It is more likely for a slightly lazy programmer to believe that removing a file would work and that they do not have to distinguish between directories (with contents) and files themself, because of the function's recursive nature and how it distinguishes between files and directories when removing them. Follow-up for #133183.
2024-11-25Rollup merge of #132730 - joboet:after_main_sync, r=Noratrieb许杰友 Jieyou Xu (Joe)-26/+59
std: allow after-main use of synchronization primitives By creating an unnamed thread handle when the actual one has already been destroyed, synchronization primitives using thread parking can be used even outside the Rust runtime. This also fixes an inefficiency in the queue-based `RwLock`: if `thread::current` was not initialized yet, it will create a new handle on every parking attempt without initializing `thread::current`. The private `current_or_unnamed` function introduced here fixes this.
2024-11-24Added a doc test for std::path::strip_prefixCrom (Thibaut CHARLES)-0/+1
2024-11-24Rollup merge of #133389 - eduardosm:stabilize-const_float_methods, r=RalfJungMatthias Krüger-1/+0
Stabilize `const_float_methods` Tracking issue: https://github.com/rust-lang/rust/issues/130843 Relnotes: #133383 Stabilized const API: ```rust // in `core` impl f32/f64 { pub const fn recip(self) -> Self; pub const fn to_degrees(self) -> Self; pub const fn to_radians(self) -> Self; pub const fn max(self, other: Self) -> Self; pub const fn min(self, other: Self) -> Self; pub const fn clamp(self, min: Self, max: Self) -> Self; pub const fn abs(self) -> Self; pub const fn signum(self) -> Self; pub const fn copysign(self, sign: Self) -> Self; } ``` Closes https://github.com/rust-lang/rust/issues/130843 r? libs-api cc `@RalfJung` -- I think the way const-stability attributes work have change a bit since the last time a wrote a const-stabilization PR, please make sure I got them right.
2024-11-24Auto merge of #132611 - compiler-errors:async-prelude, r=ibraheemdevbors-0/+3
Add `AsyncFn*` to the prelude in all editions The general vibe is that we will most likely stabilize the `feature(async_closure)` *without* the `async Fn()` trait bound modifier. Without `async Fn()` bound syntax, this necessitates users to spell the bound like `AsyncFn()`. Since `core::ops::AsyncFn` is not in the prelude, users will need to import these any time they actually want to use the trait. This seems annoying, so let's add these traits to the prelude unstably. We're trying to work on the general vision of `async` trait bound modifier in general in: https://github.com/rust-lang/rfcs/pull/3710, however that RFC still needs more time for consensus to converge, and we've decided that the value that users get from calling the bound `async Fn()` is *not really* worth blocking landing async closures in general.
2024-11-23Stabilize `const_float_methods`Eduardo Sánchez Muñoz-1/+0
2024-11-23Rollup merge of #131505 - madsmtm:darwin_user_temp_dir, r=dtolnay许杰友 Jieyou Xu (Joe)-7/+111
use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` as a `TMPDIR` fallback on Darwin Rebased version of https://github.com/rust-lang/rust/pull/100824, FCP has completed there. Motivation from https://github.com/rust-lang/rust/pull/100824#issuecomment-1262264127: > This is a behavioral change in an edge case on Darwin platforms (macOS, iOS, ...). > > Specifically, this changes it so that iff `TMPDIR` is unset in the environment, then we use `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)` to query the user temporary directory (previously we just returned `"/tmp"`). If this fails (probably possible in a sandboxed program), only then do we fallback to `"/tmp"` (as before). > > The motivations here are two-fold: > > 1. This is better for security, and is in line with the [platform security recommendations](https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585-SW10), as it is unavailable to other users (although it is the same value as seen by all other processes run by the same user). > 2. This is a more consistent fallback for when `getenv("TMPDIR")` is unavailable, as `$TMPDIR` is usually initialized to the `DARWIN_USER_TEMP_DIR`. > > It seems quite unlikely that anybody will break because of this, and I think it falls under the carve-out we have for platform specific behavior: https://doc.rust-lang.org/nightly/std/io/index.html#platform-specific-behavior. Closes https://github.com/rust-lang/rust/issues/99608. Closes https://github.com/rust-lang/rust/pull/100824. ``@rustbot`` label O-apple T-libs-api r? Dylan-DPC
2024-11-22Rollup merge of #133264 - lolbinarycat:os-string-truncate, r=joboetMichael Goulet-4/+8
implement OsString::truncate part of #133262
2024-11-22aix: create shim for lgammaf_rHenry Jiang-1/+9
2024-11-22Rollup merge of #133337 - ColinFinck:thread-scoped-fix-typo, r=joboet许杰友 Jieyou Xu (Joe)-1/+1
Fix typo in `std::thread::Scope::spawn` documentation. Just a simple fix for a typo that caught my attention.
2024-11-22Rollup merge of #133330 - RalfJung:close, r=the8472许杰友 Jieyou Xu (Joe)-10/+11
library: update comment around close() r? `@the8472`
2024-11-22Rollup merge of #133313 - thesummer:fix-arc4random, r=cuviper许杰友 Jieyou Xu (Joe)-2/+0
Use arc4random of libc for RTEMS target Switch to the `arc4random` from libc. It is available since libc 0.2.162
2024-11-22Rollup merge of #133238 - heiher:loong-stdarch-rexport, r=Amanieu许杰友 Jieyou Xu (Joe)-0/+2
re-export `is_loongarch_feature_detected` r? ``@Amanieu``
2024-11-22Fix typo in `std::thread::Scope::spawn` documentation.Colin Finck-1/+1
2024-11-22library: update comment around close()Ralf Jung-10/+11
2024-11-22Don't try to use confstr in MiriMads Marquart-4/+6
2024-11-21Use arc4random of libc for RTEMS targetJan Sommer-2/+0
Is available since libc 0.2.162
2024-11-21Mention that std::fs::remove_dir_all fails on filesPanagiotis "Ivory" Vasilopoulos-1/+2
This is explicitly mentioned for std::fs::remove_file's documentation, but not in the aforementioned function. It is more likely for a slightly lazy programmer to believe that removing a file would work and that they do not have to distinguish between directories (with contents) and files themself, because of the function's recursive nature and how it distinguishes between files and directories when removing them.
2024-11-20implement OsString::truncatebinarycat-4/+8
2024-11-20Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplettMatthias Krüger-2/+4
Mark `get_mut` and `set_position` in `std::io::Cursor` as const. Relevant tracking issue: #130801 The methods `get_mut` and `set_position` can trivially be marked as const due to #57349 being stabilised.
2024-11-20Rollup merge of #129838 - Ayush1325:uefi-process-args, r=joboetMatthias Krüger-12/+56
uefi: process: Add args support - Wrap all args with quotes. - Escape ^ and " inside quotes using ^. - Doing reverse of arg parsing: https://github.com/rust-lang/rust/blob/d571ae851d93541bef826c3c48c1e9ad99da77d6/library/std/src/sys/pal/uefi/args.rs#L81 r​? joboet
2024-11-20re-export `is_loongarch_feature_detected`WANG Rui-0/+2
2024-11-19UniqueRc: platform-specific AsFd/Handle/etc impls to mirror RcZachary S-0/+33
2024-11-19Rollup merge of #133183 - n0toose:improve-remove-dir-docs, r=joboetMatthias Krüger-0/+4
Mention std::fs::remove_dir_all in std::fs::remove_dir
2024-11-19Rollup merge of #125405 - m-ou-se:thread-add-spawn-hook, r=WaffleLapkinMatthias Krüger-7/+175
Add std::thread::add_spawn_hook. Implementation of https://github.com/rust-lang/rfcs/pull/3642
2024-11-19Update doc comments for spawn hook.Mara Bos-2/+6
2024-11-19Address review comments.Mara Bos-7/+6
Co-authored-by: waffle <waffle.lapkin@gmail.com>
2024-11-19Fix tracking issue.Mara Bos-1/+1
2024-11-19Add tracking issue.Mara Bos-2/+2
2024-11-19Use Send + Sync for spawn hooks.Mara Bos-2/+2
2024-11-19Add thread Builder::no_hooks().Mara Bos-7/+24
2024-11-19Update thread spawn hooks.Mara Bos-35/+84
1. Make the effect thread local. 2. Don't return a io::Result from hooks.
2024-11-19Use add_spawn_hook for libtest's output capturing.Mara Bos-4/+0