about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-02-25fix: attr cast for espidfSergio Gasquez-1/+1
2025-02-25Use `.expect(..)` insteadMahmoud Mazouz-5/+10
2025-02-25Auto merge of #137571 - tgross35:rollup-i1tcnv1, r=tgross35bors-17/+19
Rollup of 8 pull requests Successful merges: - #134655 (Stabilize `hash_extract_if`) - #135933 (Explain how Vec::with_capacity is faithful) - #136668 (Stabilize `core::str::from_utf8_mut` as `const`) - #136775 (Update `String::from_raw_parts` safety requirements) - #137109 (stabilize extract_if) - #137349 (Implement `read_buf` for zkVM stdin) - #137493 (configure.py: don't instruct user to run nonexistent program) - #137516 (remove some unnecessary rustc_const_unstable) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-24Rollup merge of #137543 - petrochenkov:wintest, r=ChrisDentonMichael Goulet-0/+4
std: Fix another new symlink test on Windows Checking for `got_symlink_permission` first is a standard procedure for such tests.
2025-02-24Rollup merge of #137321 - aviraxp:patch-1, r=cuviperMichael Goulet-1/+3
Correct doc about `temp_dir()` behavior on Android Since commit https://github.com/aosp-mirror/platform_frameworks_base/commit/d5ccb038f69193fb63b5169d7adc5da19859c9d8, `TMPDIR` will be set to application's cache dir when app starts.
2025-02-24Rollup merge of #137349 - thaliaarchi:io-optional-methods/zkvm, r=NoratriebTrevor Gross-1/+9
Implement `read_buf` for zkVM stdin For the zkVM, even when a guest buffer is uninitialized, from the host's perspective it is just a normal piece of memory which was initialized before letting the guest write into it. This makes `sys_read` safe to use with an uninitialized buffer. See https://github.com/risc0/risc0/issues/2853. cc `@bobbobbio,` `@flaub` r? `@Noratrieb` Tracked in https://github.com/rust-lang/rust/issues/136756
2025-02-24Rollup merge of #134655 - GrigorenkoPV:hash_extract_if, r=cuviperTrevor Gross-16/+10
Stabilize `hash_extract_if` FCP complete: https://github.com/rust-lang/rust/issues/59618#issuecomment-2674880530 Tracking issue: #59618 Closes #59618
2025-02-24span: add a "future" editionDavid Wood-0/+15
It's hard to implement edition migrations without having a perma-unstable "future" edition to target.
2025-02-24std: Fix another new symlink test on WindowsVadim Petrochenkov-0/+4
2025-02-24Remove speculation on cause of errorMahmoud Mazouz-1/+1
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-02-24Rollup merge of #137482 - rust9x:win-file-open-truncate, r=ChrisDentonJacob Pratt-25/+11
Windows: use existing wrappers in `File::open_native` Just a small improvement I've noticed - prevents accidents regarding `SetFileInformationByHandle` parameters. Probably ``@ChrisDenton`` since we talked about it on discord :)
2025-02-23Rollup merge of #136543 - RalfJung:round-ties-even, r=tgross35Trevor Gross-4/+4
intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even intrinsic LLVM has three intrinsics here that all do the same thing (when used in the default FP environment). There's no reason Rust needs to copy that historically-grown mess -- let's just have one intrinsic and leave it up to the LLVM backend to decide how to lower that. Suggested by `@hanna-kruppe` in https://github.com/rust-lang/rust/issues/136459; Cc `@tgross35` try-job: test-various
2025-02-23Win: use existing wrappers for `SetFileInformationByHandle` in ↵Dennis Duda-25/+11
`File::open_native`
2025-02-23Return error on unexpected termination in `Thread::join`.Mahmoud Mazouz-1/+5
There is a time window during which the OS can terminate a thread before stdlib can retreive its `Packet`. Currently the `Thread::join` panics with no message in such an event, which makes debugging difficult; fixes #124466.
2025-02-23Auto merge of #137237 - cuviper:stage0, r=Mark-Simulacrumbors-8/+8
Master bootstrap update https://forge.rust-lang.org/release/process.html#master-bootstrap-update-tuesday r? `@Mark-Simulacrum`
2025-02-23Rollup merge of #137194 - kornelski:ftls, r=tgross35Jacob Pratt-7/+25
More const {} init in thread_local `const {}` in `thread_local!` gets an optimization just based on the syntax, rather than the expression being const-compatible. This is easy to miss, so I've added more examples to the docs. I've also added `const {}` in a couple of places in std where this optimization has been missed.
2025-02-23Rollup merge of #136826 - xizheyin:issue-136737, r=thomccJacob Pratt-26/+45
Replace mem::zeroed with mem::MaybeUninit::uninit for large struct in Unix As discussion in #136737. - Replace `mem::zeroed()` with `MaybeUninit::uninit()` for `sockaddr_storage` in `accept()` and `recvfrom()` since these functions fill in the address structure - Replace `mem::zeroed()` with `MaybeUninit::uninit()` for `pthread_attr_t` in thread-related functions since `pthread_attr_init()` initializes the structure - Add references to man pages to document this behavior
2025-02-23[illumos] attempt to use posix_spawn to spawn processesRain-1/+16
illumos has `posix_spawn`, and the very newest versions also have `_addchdir`, so use that. This is a nice ~4x performance improvement for process creation. My go-to as usual is nextest against the clap repo, which acts as a stress test for process creation -- with [this commit]: ```console $ cargo nextest run -E 'not test(ui_tests) and not test(example_tests)' before: Summary [ 1.747s] 879 tests run: 879 passed, 2 skipped after: Summary [ 0.445s] 879 tests run: 879 passed, 2 skipped ``` [this commit]: https://github.com/clap-rs/clap/commit/fde45f9aea766fb8de46e3d46e6575f393c3b6b9
2025-02-23Rollup merge of #135501 - tgross35:stdlib-dependencies-private, r=bjorn3Matthias Krüger-2/+2
Inject `compiler_builtins` during postprocessing and ensure it is made private Follow up of https://github.com/rust-lang/rust/pull/135278 Do the following: * Inject `compiler_builtins` during postprocessing, rather than injecting `extern crate compiler_builtins as _` into the AST * Do not make dependencies of `std` private by default (this was added in #135278) * Make sure sysroot crates correctly mark their dependencies private/public * Ensure that marking a dependency private makes its dependents private by default as well, unless otherwise specified * Do the `compiler_builtins` update that has been blocked on this There is more detail in the commit messages. This includes the changes I was working on in https://github.com/rust-lang/rust/pull/136226. try-job: test-various try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: i686-mingw-1 try-job: i686-mingw-2
2025-02-22make the new intrinsics safeRalf Jung-4/+4
2025-02-22Rollup merge of #137388 - ↵Matthias Krüger-0/+4
PaulDance:disable-rename-posix-semantics-tests-under-win7, r=ChrisDenton Fix(lib/fs/tests): Disable rename POSIX semantics FS tests under Windows 7 Would otherwise fail there. The Windows7-specific parts were left pretty much untouched by the changes introduced by 51df98ddb094b39b2e17d24f887cd66c52560ef6, so it is expected that these tests fail under Windows 7 as they were probably written to run under Windows 10+ only.
2025-02-21Fix(lib/fs/tests): Disable rename POSIX semantics FS tests under Windows 7Paul Mabileau-0/+4
Would otherwise fail there. The Windows7-specific parts were left pretty much untouched by the changes introduced by 51df98ddb094b39b2e17d24f887cd66c52560ef6, so it is expected that these tests fail under Windows 7 as they were probably written to run under Windows 10+ only. Signed-off-by: Paul Mabileau <paul.mabileau@harfanglab.fr>
2025-02-21Rollup merge of #137353 - thaliaarchi:io-optional-methods/wasi-stdin, ↵Matthias Krüger-1/+6
r=alexcrichton Implement `read_buf` for WASI stdin `WasiFd::read_buf` already exists. Simply use it in `Stdin`. cc `@alexcrichton` Tracked in https://github.com/rust-lang/rust/issues/136756
2025-02-21Rollup merge of #137336 - riverbl:stabilise-os-str-display, r=tgross35Matthias Krüger-7/+5
Stabilise `os_str_display` Closes #120048.
2025-02-21Replace some instances of `pub` with `pub(crate)`Trevor Gross-2/+2
The recent fixes to private dependencies exposed some cases in the UEFI module where private dependencies are exposed in a public interface. These do not need to be crate-public, so change them to `pub(crate)`.
2025-02-21Use faster thread_local! for stdoutKornel-1/+1
2025-02-21Use faster thread_local in current_thread_id()Kornel-1/+18
2025-02-21Highlight thread_local! const init in docsKornel-5/+6
2025-02-21Auto merge of #137192 - kornelski:windows-tls-lto, r=ChrisDentonbors-3/+1
Remove obsolete Windows ThinLTO+TLS workaround The bug #109797 has been fixed by #129079, so this workaround is no longer needed.
2025-02-21Clarify/update comments in `BufRead::read_line`'s default bodyFrank Steffahn-1/+1
with where to *actually* look for more details
2025-02-20Implement read_buf for WASI stdinThalia Archibald-1/+6
2025-02-20Implement read_buf for zkVM stdinThalia Archibald-1/+9
For the zkVM, even when a guest buffer is uninitialized, from the host's perspective it is just a normal piece of memory which was initialized before letting the guest write into it. This makes `sys_read` safe to use with an uninitialized buffer. See https://github.com/risc0/risc0/issues/2853.
2025-02-20Rollup merge of #137270 - QianNangong:master, r=ChrisDentonJubilee-8/+8
Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306 That commit make it failed to build `std` with `*-win7-windows-msvc` so fix it.
2025-02-20Stabilise `os_str_display`riverbl-7/+5
2025-02-20Undeprecate env::home_dirArlo Siemsen-5/+0
2025-02-21Correct doc about `temp_dir()` behavior on AndroidWang Han-1/+3
Since commit https://github.com/aosp-mirror/platform_frameworks_base/commit/d5ccb038f69193fb63b5169d7adc5da19859c9d8, `TMPDIR` will be set to application's cache dir when app starts.
2025-02-19Skip scanning for surrogates when not known validThalia Archibald-1/+1
2025-02-19Add fast path for displaying pre-validated Wtf8BufThalia Archibald-2/+26
2025-02-19Auto merge of #137290 - matthiaskrgr:rollup-a7xdbi4, r=matthiaskrgrbors-116/+164
Rollup of 8 pull requests Successful merges: - #120580 (Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants) - #132268 (Impl TryFrom<Vec<u8>> for String) - #136093 (Match Ergonomics 2024: update old-edition behavior of feature gates) - #136344 (Suggest replacing `.` with `::` in more error diagnostics.) - #136690 (Use more explicit and reliable ptr select in sort impls) - #136815 (CI: Stop /msys64/bin from being prepended to PATH in msys2 shell) - #136923 (Lint `#[must_use]` attributes applied to methods in trait impls) - #137155 (Organize `OsString`/`OsStr` shims) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-19Rollup merge of #137155 - thaliaarchi:wtf8-organize, r=ChrisDentonMatthias Krüger-109/+154
Organize `OsString`/`OsStr` shims Synchronize the `bytes.rs` and `wtf8.rs` shims for `OsString`/`OsStr` so they're easier to diff between each other. This is mostly ordering items the same between the two. I tried to minimize moves and went for the average locations between the files. With them in the same order, it is clear that `FromInner<_>` is not implemented for `bytes::Buf` and `Clone::clone_from` is not implemented for `wtf8::Buf`, but they are for the other. Fix that. I added #[inline] to all inherent methods of the `OsString`/`OsStr` shims, because it seemed that was already the rough pattern. `bytes.rs` has more inlining than `wtf8.rs`, so I added the corresponding ones to `wtf8.rs`. Then, the common missing ones have no discernible pattern to me. They're not divided by non-allocating/allocating. Perhaps the pattern is that UTF-8 validation isn't inlined? Since these types are merely the inner values in `OsStr`/`OsString`, I put inline on all methods and let those public types dictate inlining. I have not inspected codegen or run benchmarks. Also, touch up some (private) documentation comments. r? ``````@ChrisDenton``````
2025-02-19Rollup merge of #120580 - HTGAzureX1212:HTGAzureX1212/issue-45795, r=m-ou-seMatthias Krüger-7/+10
Add `MAX_LEN_UTF8` and `MAX_LEN_UTF16` Constants This pull request adds the `MAX_LEN_UTF8` and `MAX_LEN_UTF16` constants as per #45795, gated behind the `char_max_len` feature. The constants are currently applied in the `alloc`, `core` and `std` libraries.
2025-02-19Rollup merge of #136794 - cberner:stabilize, r=joshtriplettMatthias Krüger-10/+5
Stabilize file_lock Closes #130994
2025-02-19Rollup merge of #136347 - allevo:patch-1, r=AmanieuMatthias Krüger-0/+1
Add a bullet point to `std::fs::copy` I needed to copy a file but I got the following error: ``` Os { code: 2, kind: NotFound, message: "No such file or directory" } ``` After read the documentation, I though the error was generated by the `from` parameter, forgetting the `to` part. Anyway, I got the error because the parent folder of `to` didn't exist. Even if the documentation explicitly saying `but is not limited to just these cases`, I would like to add this case because I spent 3 hours around it. This PR just wants to put a mention about it.
2025-02-19Rollup merge of #136301 - hkBst:patch-33, r=thomccMatthias Krüger-2/+8
Improve instant docs This should be enough to close #79881.
2025-02-19fix by commentsxizheyin-21/+17
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-19Fix `*-win7-windows-msvc` target since 26eeac1a1e9fe46ffd80dd0d3dafdd2c2a644306Li Keqing-8/+8
2025-02-19Update library/std/src/fs.rsTommaso Allevi-1/+1
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2025-02-19remove assume_init in stack_overflowxizheyin-7/+9
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-02-18Auto merge of #137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgrbors-38/+58
Rollup of 10 pull requests Successful merges: - #135711 (Do not ICE on default_field_value const with lifetimes) - #136599 (librustdoc: more usages of `Joined::joined`) - #136876 (Locking documentation updates) - #137000 (Deeply normalize item bounds in new solver) - #137126 (fix docs for inherent str constructors) - #137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions) - #137191 (Update mdbook and move error_index_generator) - #137203 (Improve MIR modification) - #137206 (Make E0599 a structured error) - #137218 (misc `layout_of` cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-19std::fs: slightly reformat `remove_dir_all` error docs许杰友 Jieyou Xu (Joe)-3/+5
To make the error cases easier to spot on a quick glance.