about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2025-03-10Readd os::cygwin::raw as pub(crate)王宇逸-1/+5
2025-03-10Unify cygwin & horizon random impl王宇逸-16/+5
2025-03-10Impl cygwin rand with getrandom王宇逸-11/+13
2025-03-10Remove std::os::cygwin::raw王宇逸-91/+0
2025-03-10Fix code style王宇逸-4/+14
2025-03-10Fix building for cygwin王宇逸-5/+14
2025-03-10Fix `std::sys::unix::set_linger` for CygwinOokiineko-0/+11
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-10Initial STD support for Cygwin王宇逸-7/+244
Signed-off-by: Ookiineko <chiisaineko@protonmail.com>
2025-03-10Add comments for #[no_sanitize(cfi)] in stdlibBastian Kersting-1/+11
2025-03-10Disable CFI for weakly linked syscallsBastian Kersting-0/+27
Currently, when enabling CFI via -Zsanitizer=cfi and executing e.g. std::sys::random::getrandom, we can observe a CFI violation. This is the case for all consumers of the std::sys::pal::weak::weak macro, as it is defining weak functions which don't show up in LLVM IR metadata. CFI fails for all these functions. Similar to other such cases in https://github.com/rust-lang/rust/issues/115199, this change stops emitting the CFI typecheck for consumers of the macro via the \#[no_sanitize(cfi)] attribute.
2025-03-10Implement default methods for io::Empty and io::SinkThalia Archibald-11/+216
Eliminate any redundant, unobservable logic from the their default method implementations. The observable changes are that `Write::write_fmt` for both types now ignores the formatting arguments, so a user fmt impl which has side effects is not invoked, and `Write::write_all_vectored` for both types does not advance the borrowed buffers. Neither behavior is guaranteed by the docs and the latter is documented as unspecified. `Empty` is not marked as vectored, so that `Chain<Empty, _>` and `Chain<_, Empty>` are not forced to be vectored.
2025-03-10Rollup merge of #138074 - thaliaarchi:hermit-seek, r=ChrisDentonMatthias Krüger-5/+22
Support `File::seek` for Hermit `lseek` was added in `hermit-abi` in commit [87dd201](https://github.com/hermit-os/hermit-rs/commit/87dd201a14ac7661e1a4b761273e24d750496286) (add missing interface for lseek, 2024-07-15), which was just released in version 0.5.0. cc ``@mkroening,`` ``@stlankes`` Fixes https://github.com/hermit-os/hermit-rs/issues/652
2025-03-10Implement read_buf and vectored read/write for SGX stdioThalia Archibald-3/+49
2025-03-10Copy from userspace to MaybeUninitJethro Beekman-3/+42
Co-authored-by: Thalia Archibald <thalia@archibald.dev>
2025-03-10uefi: fs: Partially implement FileAttrAyush Singh-15/+11
- Just the permission and file type. - FileTimes will need some new conversion functions and thus will come with a future PR. Trying to keep things simple here. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-10uefi: fs: Implement FileTypeAyush Singh-30/+10
- Similar to FilePermissions, using bool to represent the bitfield. - FileType cannot be changed, so no need to worry about converting back to attribute. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-10uefi: fs: Implement FilePermissionAyush Singh-21/+16
- UEFI file permissions are indicated using a u64 bitfield used for readonly/filetype, etc. - Using normal bool with to and from attribute conversions to FilePermission from overriding some other bitfields. Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-09std: move stdio to `sys`joboet-150/+77
As per #117276, this moves the platform definitions of `Stdout` and friends into `sys`. This PR also unifies the UNIX and Hermit implementations and moves the `__rust_print_err` function needed by libunwind on SGX into the dedicated module for such helper functions.
2025-03-09Support File::seek for HermitThalia Archibald-5/+22
2025-03-09Rollup merge of #138276 - bdbai:fix-uwp-ntopenfile, r=ChrisDentonMatthias Krüger-0/+11
Lazy load NtOpenFile for UWP Lazily load `NtOpenFile` to allow libraries targeting UWP to build and link. Fixes #138257 . r? `@ChrisDenton`
2025-03-09Lazy load NtOpenFile for UWPbdbai-0/+11
2025-03-09expose `is_s390x_feature_detected` from `std::arch`Folkert de Vries-0/+2
2025-03-08Move fs into sysThalia Archibald-46/+61
2025-03-08Add inherent versions of MaybeUninit::fill methods for slicesltdk-2/+1
2025-03-08Rollup merge of #138189 - GuillaumeGomez:env-var, r=joshtriplettJacob Pratt-0/+3
Mention `env` and `option_env` macros in `std::env::var` docs Fixes https://github.com/rust-lang/rust/issues/138159. Just like there are mentions in `env!` and `option_env!` docs to `std::env::var`, it'd be nice to have a "mention back" as well.
2025-03-08Rollup merge of #137528 - ChrisDenton:rename-win, r=joboetJacob Pratt-124/+57
Windows: Fix error in `fs::rename` on Windows 1607 Fixes #137499 There's a bug in our Windows implementation of `fs::rename` that only manifests on a specific version of Windows. Both newer and older versions of Windows work. I took the safest route to fixing this by using the old `MoveFileExW` function to implement this and only falling back to the new behaviour if that fails. This is similar to what is done in `unlink` (just above this function). try-job: dist-x86_64-mingw try-job: dist-x86_64-msvc
2025-03-07Rollup merge of #137606 - davidtwco:next-edition, r=traviscross,ehussJacob Pratt-0/+15
add a "future" edition This idea has been discussed previously [on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/213817-t-lang/topic/Continuous.20edition-like.20changes.3F/near/432559262) (though what I've implemented isn't exactly the "next"/"future" editions proposed in that message, just the "future" edition). I've found myself prototyping changes that involve edition migrations and wanting to target an upcoming edition for those migrations, but none exists. This should be permanently unstable and not removed.
2025-03-07Mention `env` and `option_env` macros in `std::env::var` docsGuillaume Gomez-0/+3
2025-03-07Rollup merge of #134797 - spastorino:ergonomic-ref-counting-1, r=nikomatsakisMatthias Krüger-2/+7
Ergonomic ref counting This is an experimental first version of ergonomic ref counting. This first version implements most of the RFC but doesn't implement any of the optimizations. This was left for following iterations. RFC: https://github.com/rust-lang/rfcs/pull/3680 Tracking issue: https://github.com/rust-lang/rust/issues/132290 Project goal: https://github.com/rust-lang/rust-project-goals/issues/107 r? ```@nikomatsakis```
2025-03-07Return OutOfMemoryError and update docsChris Denton-3/+3
2025-03-07Windows: Use MoveFileEx by default in `fs:rename`Chris Denton-123/+56
2025-03-07Auto merge of #138155 - matthiaskrgr:rollup-xq5buio, r=matthiaskrgrbors-150/+121
Rollup of 6 pull requests Successful merges: - #137674 (Enable `f16` for LoongArch) - #138034 (library: Use `size_of` from the prelude instead of imported) - #138060 (Revert #138019 after further discussion about how hir-pretty printing should work) - #138073 (Break critical edges in inline asm before code generation) - #138107 (`librustdoc`: clippy fixes) - #138111 (Use `default_field_values` for `rustc_errors::Context`, `rustc_session::config::NextSolverConfig` and `rustc_session::config::ErrorOutputType`) r? `@ghost` `@rustbot` modify labels: rollup
2025-03-07Rollup merge of #138034 - thaliaarchi:use-prelude-size-of, r=tgross35Matthias Krüger-150/+121
library: Use `size_of` from the prelude instead of imported Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80. try-job: test-various try-job: x86_64-gnu try-job: x86_64-msvc-1
2025-03-07Rollup merge of #137832 - wgwoods:fix-bufreader-peek, r=joboetMatthias Krüger-5/+5
Fix crash in BufReader::peek() `bufreader_peek` tracking issue: #128405 This fixes a logic error in `Buffer::read_more()` that would make `BufReader::peek()` expose uninitialized data and/or segfault if `read_more()` was called with a partially-full buffer and a non-empty inner reader.
2025-03-07Rollup merge of #137777 - thaliaarchi:os_string-push-str, r=joboetMatthias Krüger-2/+58
Specialize `OsString::push` and `OsString as From` for UTF-8 When concatenating two WTF-8 strings, surrogate pairs at the boundaries need to be joined. However, since UTF-8 strings cannot contain surrogate halves, this check can be skipped when one string is UTF-8. Specialize `OsString::push` to use a more efficient concatenation in this case. The WTF-8 version of `OsString` tracks whether it is known to be valid UTF-8 with its `is_known_utf8` field. Specialize `From<AsRef<OsStr>>` so this can be set for UTF-8 string types. Unfortunately, a specialization for `T: AsRef<str>` conflicts with `T: AsRef<OsStr>`, so stamp out string types with a macro. r? ``@ChrisDenton``
2025-03-07Rollup merge of #137107 - thaliaarchi:io-optional-methods/cursors, r=joboetMatthias Krüger-14/+146
Override default `Write` methods for cursor-like types Override the default `io::Write` methods for cursor-like types to provide more efficient versions. Writes to resizable containers already write everything, so implement `write_all` and `write_all_vectored` in terms of those. For fixed-sized containers, cut out unnecessary error checking and looping for those same methods. | `impl Write for T` | `vectored` | `all` | `all_vectored` | `fmt` | | ------------------------------- | ---------- | ----- | -------------- | ------- | | `&mut [u8]` | Y | Y | new | | | `Vec<u8>` | Y | Y | new | #137762 | | `VecDeque<u8>` | Y | Y | new | #137762 | | `std::io::Cursor<&mut [u8]>` | Y | new | new | | | `std::io::Cursor<&mut Vec<u8>>` | Y | new | new | #137762 | | `std::io::Cursor<Vec<u8>>` | Y | new | new | #137762 | | `std::io::Cursor<Box<[u8]>>` | Y | new | new | | | `std::io::Cursor<[u8; N]>` | Y | new | new | | | `core::io::BorrowedCursor<'_>` | new | new | new | | Tracked in https://github.com/rust-lang/rust/issues/136756. # Open questions Is it guaranteed by `Write::write_all` that the maximal write is performed when not everything can be written? Its documentation describes the behavior of the default implementation, which writes until a 0-length write is encountered, thus implying that a maximal write is expected. In contrast, `Read::read_exact` declares that the contents of the buffer are unspecified for short reads. If it were allowed, these cursor-like types could bail on the write altogether if it has insufficient capacity.
2025-03-06library: Use size_of from the prelude instead of importedThalia Archibald-150/+121
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-03-06Add examples in stdlib demonstrating the use syntaxSantiago Pastorino-2/+7
2025-03-06Rollup merge of #137327 - arlosi:home-dir, r=Mark-SimulacrumMichael Goulet-5/+0
Undeprecate env::home_dir #132515 fixed the implementation of `env::home_dir`, but didn't remove the deprecation. Based on [this comment](https://github.com/rust-lang/rust/pull/132515#discussion_r1829715262), libs-api decided to undeprecate in the next release. Let's do that! cc #132650
2025-03-05Rollup merge of #137477 - Ayush1325:uefi-service-binding, r=Noratrieb许杰友 Jieyou Xu (Joe)-1/+60
uefi: Add Service Binding Protocol abstraction - Some UEFI protocols such as TCP4, TCP6, UDP4, UDP6, etc are managed by service binding protocol. - A new instance of such protocols is created and destroyed using the corresponding service binding protocol. - This PR adds abstractions to make using such protocols simpler using Rust Drop trait. - The reason to add these abstractions in a seperate PR from TCP4 Protocol is to make review easier. [EFI_SERVICE_BINDING_PROTCOL](https://uefi.org/specs/UEFI/2.11/11_Protocols_UEFI_Driver_Model.html#efi-service-binding-protocol) cc ````@nicholasbishop````
2025-03-05Rollup merge of #137463 - sunshowers:illumos-posix-spawn, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-1/+16
[illumos] attempt to use posix_spawn to spawn processes illumos has `posix_spawn`, and the very newest versions also have `_addchdir`, so use that. POSIX standardized this function so I also added a weak symbol lookup for the non `_np` version. (illumos has both.) This probably also works on Solaris, but I don't have access to an installation to validate this so I decided to focus on illumos instead. 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-03-05Rollup merge of #137240 - jieyouxu:remove_dir_all, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-3/+5
Slightly reformat `std::fs::remove_dir_all` error docs To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀 cc #137230.
2025-03-05Rollup merge of #136798 - pcorwin:master, r=tgross35许杰友 Jieyou Xu (Joe)-0/+34
Added documentation for flushing per #74348 Resolves #74348
2025-03-04Added documentation for flushingpcorwin-0/+34
2025-03-04Fix test hangs on AIXHenry Jiang-4/+19
2025-03-04Fix some typosfuyangpengqi-1/+1
Signed-off-by: fuyangpengqi <995764973@qq.com>
2025-03-04exit: document interaction with CRalf Jung-4/+32
2025-03-02Rollup merge of #137375 - steffahn:clarify-read_line-comment, r=Mark-SimulacrumMatthias Krüger-1/+1
Minor internal comments fix for `BufRead::read_line` Just a little fix that came up while I was reading through this source code, and had to search for a few minutes to find out what was actually *meant* here.
2025-03-03uefi: helpers: Add DevicePathNode abstractionsAyush Singh-0/+179
- UEFI device path is a series of nodes layed out in a contiguous memory region. So it makes sense to use Iterator abstraction for modeling DevicePaths - This PR has been split off from #135368 for easier review. The allow dead_code will be removed in #135368 Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-02doc: clarify that consume can be called after BufReader::peekbinarycat-1/+5