about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-02-11Document that locking a file fails on Windows if the file is opened only for ↵Josh Triplett-0/+15
append
2025-02-11Reword file lock documentation to clarify advisory vs mandatoryJosh Triplett-35/+40
Remove the word "advisory", and make it more explicit that the lock may be advisory or mandatory depending on platform.
2025-02-11Rollup merge of #136354 - hkBst:patch-34, r=ibraheemdevMatthias Krüger-7/+34
Update docs for impl keyword This started as a fix for #79878, but also introduces some structure (headings), and elaborates a tiny bit on impl Trait syntax.
2025-02-11Update docs for impl keywordMarijn Schouten-7/+34
2025-02-11Rollup merge of #136704 - benschulz:patch-1, r=ibraheemdevJacob Pratt-2/+2
Improve examples for file locking The `lock` and `try_lock` documentation states that "if the file not open for writing, it is unspecified whether this function returns an error." With this change, the examples use `File::create` instead of `File::open`, eliminating the possibility of someone blindly copying code with unspecified behavior.
2025-02-10Fix long lines which rustfmt fails to formatThalia Archibald-106/+45
rustfmt fails to format this match expression, because it has several long string literals over the maximum line width. This seems to exhibit rustfmt issues #3863 (Gives up on chains if any line is too long) and #3156 (Fail to format match arm when other arm has long line).
2025-02-10Fix &&str and trailing commas in io::const_error!Thalia Archibald-91/+75
2025-02-10Use io::const_error! when possible over io::Error::newThalia Archibald-10/+9
2025-02-10Implement `read*_exact` for `std:io::repeat`Benoît du Garreau-0/+11
cc #136756
2025-02-10Rollup merge of #136705 - compiler-errors:edition-library, r=jhprattJubilee-75/+75
Some miscellaneous edition-related library tweaks Some library edition tweaks that can be done separately from upgrading the whole standard library to edition 2024 (which is blocked on getting the submodules upgraded, for example)
2025-02-10Rollup merge of #136552 - ChrisDenton:option-find-handle, r=Mark-SimulacrumJubilee-10/+6
Use an `Option` for `FindNextFileHandle` in `ReadDir` instead of `INVALID_FILE_HANDLE` sentinel value Sometimes we store an invalid handle when we don't want to return an error. We then check the handle before use in order to avoid actually using the invalid handle. However, using an `Option` for this is better and avoids us forgetting to check the handle is valid. This was noticed due to us closing the handle without checking for validity: https://github.com/rust-lang/rust/blob/bd6a6777f5cbbec549f123995026cef76d1e6b84/library/std/src/sys/pal/windows/fs.rs#L148-L151
2025-02-09Stabilize file_lockChristopher Berner-10/+5
2025-02-09Fix pattern matching mode changes and unsafe_op_in_unsafe_fnMichael Goulet-3/+3
2025-02-09Mark extern blocks as unsafeMichael Goulet-69/+69
2025-02-09Mark link_section attr with unsafeMichael Goulet-3/+3
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-110/+120
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-09Auto merge of #136754 - Urgau:rollup-qlkhjqr, r=Urgaubors-6/+44
Rollup of 5 pull requests Successful merges: - #134679 (Windows: remove readonly files) - #136213 (Allow Rust to use a number of libc filesystem calls) - #136530 (Implement `x perf` directly in bootstrap) - #136601 (Detect (non-raw) borrows of null ZST pointers in CheckNull) - #136659 (Pick the max DWARF version when LTO'ing modules with different versions ) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-08Rollup merge of #136686 - bjoernager:master, r=jhprattJubilee-8/+8
Clean up `HashMap` and `HashSet` docs. This commit makes some small, pedantic changes to the docs for `HashMap` and `HashSet`, which fixes that: * "HashMap" is not always formatted as code (as in `HashMap`), and that * `HashSet` sometimes references `HashMap` instead of itself.
2025-02-09Rollup merge of #136213 - erickt:fs, r=Mark-SimulacrumUrgau-1/+17
Allow Rust to use a number of libc filesystem calls This allows Rust on Fuchsia to use a number of function calls from libc: * dirfd * fdatasync * flock with LOCK_EX, LOCK_SH, LOCK_NB, LOCK_UN * fstatat cc #120426 try-job: dist-various-2
2025-02-09Rollup merge of #134679 - ChrisDenton:rm-readonly, r=Mark-SimulacrumUrgau-5/+27
Windows: remove readonly files When calling `remove_file`, we shouldn't fail to delete readonly files. As the test makes clear, this make the Windows behaviour consistent with other platforms. This also makes us internally consistent with `remove_dir_all`. try-job: x86_64-msvc-ext1
2025-02-08Rustfmtbjorn3-110/+120
2025-02-08Rollup merge of #135696 - joboet:move_pal_io, r=NoratriebMatthias Krüger-317/+164
std: move `io` module out of `pal`, get rid of `sys_common::io` Part of #117276. This does two related things: 1. It moves the platform-specific definitions for `IoSlice`, `IoSliceMut` and `is_terminal` out of `pal` and into `sys` and unifies some of them. 2. It gets rid of `sys_common::io`, moving the non-platform-specific test helpers into `std::test_helpers` and the buffer size definition to the new `sys::io` module.
2025-02-07Rollup merge of #136682 - ChrisDenton:move-win-proc-tests, r=joboetMatthias Krüger-148/+0
Move two windows process tests to tests/ui Spawning processes from std unit tests is not something it's well suited for so moving them into tests/ui is more robust and means we don't need to hack around `cmd.exe`. Follow up to #136630
2025-02-07Rollup merge of #136635 - jieyouxu:base_port, r=joboetMatthias Krüger-30/+3
Remove outdated `base_port` calculation in std net test This was never modified since `std::net` was originally introduced in 395709ca6d39ba1e095e404e1d2a169d918b7f0c, when at that time, each CI runner was running multiple jobs concurrently. This seems to have originally caused issues with jobs fighting over the same ports. This is not the case in the current CI infrastructure, so remove this relic in favor of a simple constant base port number. I double-checked `19600` and nearby port numbers, and this isn't a well-known port number AFAICT[^1]. Closes #136633. [^1]: At the time of writing.
2025-02-07Rollup merge of #136615 - Ayush1325:uefi-net-unsupported, r=joboetMatthias Krüger-0/+374
sys: net: Add UEFI stubs - Just a copy of sys/net/unsupported. - Will make the future net PRs easier to review. - The reason for a separate folder instead of standalone file is that UEFI has separate the protocols for v4 and v6, and thus will need some abstractions to implement the Rust interface. r? ``@jhpratt``
2025-02-07Improve examples for file lockingBen Schulz-2/+2
2025-02-07std: get rid of `sys_common::io`joboet-87/+83
2025-02-07std: move `io` module out of `pal`joboet-230/+81
2025-02-07Clean up 'HashMap' and 'HashSet' docs;Gabriel Bjørnager Jensen-8/+8
2025-02-07Rollup merge of #136634 - bjoernager:const-mut-cursor, r=m-ou-seMatthias Krüger-2/+2
Stabilise `Cursor::{get_mut, set_position}` in `const` scenarios. Closes: #130801 This PR stabilises the `const_mut_cursor` feature gate.
2025-02-07Move two windows process tests to tests/uiChris Denton-148/+0
2025-02-06Rollup merge of #136152 - Urgau:stabilize-map_many_mut, r=joshtriplettMatthias Krüger-15/+17
Stabilize `map_many_mut` feature This PR stabilize `HashMap::get_many_mut` as `HashMap::get_disjoint_mut` and `HashMap::get_many_unchecked_mut` as `HashMap::get_disjoint_unchecked_mut` per FCP. FCP at https://github.com/rust-lang/rust/issues/97601#issuecomment-2532710423 Fixes #97601 r? libs
2025-02-06Stabilise 'Cursor::{get_mut, set_position}' in 'const' scenarios;Gabriel Bjørnager Jensen-2/+2
2025-02-06tests(std/net): remove outdated `base_port` calculationJieyou Xu-30/+3
This was never modified since `std::net` was originally introduced, when each CI job was running multiple jobs concurrently which caused issues with fighting over the same ports. This is not the case in the current CI infrastructure, so remove this relic.
2025-02-06tests(std): don't output to std{out,err} in `test_creation_flags` and ↵许杰友 Jieyou Xu (Joe)-3/+12
`test_proc_thread_attributes`
2025-02-06sys: net: Add UEFI stubsAyush Singh-0/+374
- Just a copy of sys/net/unsupported. - Will make the future net PRs easier to review. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-02-05Rollup merge of #136449 - joboet:move_pal_net, r=ChrisDenton许杰友 Jieyou Xu (Joe)-1036/+113
std: move network code into `sys` As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules. I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2025-02-05Rollup merge of #136418 - Ayush1325:command-env, r=jhpratt许杰友 Jieyou Xu (Joe)-3/+62
uefi: process: Add support for command environment variables Set environment variables before launching the process and restore the prior variables after the program exists. This is the same implementation as the one used by UEFI Shell Execute [0]. [0]: https://github.com/tianocore/edk2/blob/2d2642f4832ebc45cb7d5ba9430b933d953b94f2/ShellPkg/Application/Shell/ShellProtocol.c#L1700
2025-02-04Use Option for FindNextFileHandleChris Denton-10/+6
2025-02-04intrinsics: unify rint, roundeven, nearbyint in a single round_ties_even ↵Ralf Jung-4/+4
intrinsic
2025-02-04Auto merge of #136534 - jhpratt:rollup-dnz57dq, r=jhprattbors-8/+6
Rollup of 6 pull requests Successful merges: - #136398 (add UnsafeCell direct access APIs) - #136465 (Some `rustc_middle` cleanups) - #136479 (std::fs: further simplify dirent64 handling) - #136504 (Fix last compare-mode false negatives in tests) - #136511 (Add `cast_signed` and `cast_unsigned` methods for `NonZero` types) - #136518 (Add note about `FnPtr` trait being exposed as public bound) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-04Rollup merge of #136479 - RalfJung:dirent64, r=tgross35Jacob Pratt-8/+6
std::fs: further simplify dirent64 handling Follow-up to https://github.com/rust-lang/rust/pull/134678. r? `@tgross35`
2025-02-04Rollup merge of #136167 - pitaj:new_range, r=NadrierilJacob Pratt-0/+2
Implement unstable `new_range` feature Switches `a..b`, `a..`, and `a..=b` to resolve to the new range types. For rust-lang/rfcs#3550 Tracking issue #123741 also adds the re-export that was missed in the original implementation of `new_range_api`
2025-02-04Rollup merge of #135621 - bjorn3:move_tests_to_stdtests, r=NoratriebJacob Pratt-11586/+8
Move some std tests to integration tests Unit tests directly inside of standard library crates require a very fragile way of building that is hard to reproduce outside of bootstrap. Follow up to https://github.com/rust-lang/rust/pull/133859
2025-02-03Rollup merge of #136289 - Pyr0de:oncecell-docs, r=tgross35Matthias Krüger-29/+36
OnceCell & OnceLock docs: Using (un)initialized consistently Changed * `set` / `initialize` / `full` to `initialized state` * `uninitialize` / `empty` to `uninitialized state` * `f` to `f()` * Added explaination of `uninitialized state` & `initialized state` [OnceCell Docs](https://doc.rust-lang.org/nightly/std/cell/struct.OnceCell.html) [OnceLock Docs](https://doc.rust-lang.org/nightly/std/sync/struct.OnceLock.html) Fixes #85716 ``@rustbot`` label +A-docs
2025-02-03OnceCell & OnceLock docs: Using (un)initialized consistentlyPyrode-29/+36
2025-02-03std::fs: further simplify dirent64 handlingRalf Jung-8/+6
2025-02-02std: move network code into `sys`joboet-1036/+113
As per #117276, this PR moves `sys_common::net` and the `sys::pal::net` into the newly created `sys::net` module. In order to support #135141, I've moved all the current network code into a separate `connection` module, future functions like `hostname` can live in separate modules. I'll probably do a follow-up PR and clean up some of the actual code, this is mostly just a reorganization.
2025-02-02Rollup merge of #134272 - RalfJung:destabilize-rustc_encodable_decodable, ↵Matthias Krüger-10/+0
r=oli-obk Remove rustc_encodable_decodable feature This has been shown in future-compat reports since Rust 1.79 (https://github.com/rust-lang/rust/pull/116016), released June 2024. Let's see if crater still finds any issues. Part of https://github.com/rust-lang/rust/issues/134301. Cc ``@rust-lang/libs-api``
2025-02-02Rollup merge of #136133 - hkBst:patch-23, r=ibraheemdevMatthias Krüger-8/+4
Fix sentence in process::abort