about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2024-06-22Rollup merge of #126140 - eduardosm:stabilize-fs_try_exists, r=AmanieuMatthias Krüger-19/+18
Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_exists FCP completed in tracking issue. Tracking issue: https://github.com/rust-lang/rust/issues/83186 Closes https://github.com/rust-lang/rust/issues/83186 Stabilized API: ```rust mod fs { pub fn exists<P: AsRef<Path>>(path: P) -> io::Result<bool>; } ```
2024-06-22Auto merge of #124101 - the8472:pidfd-methods, r=cuviperbors-124/+265
Add PidFd::{kill, wait, try_wait} #117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: #82971
2024-06-22to extract a pidfd we must consume the childThe 8472-12/+19
As long as a pidfd is on a child it can be safely reaped. Taking it would mean the child would now have to be awaited through its pid, but could also be awaited through the pidfd. This could then suffer from a recycling race.
2024-06-22Add PidFd::{kill, wait, try_wait}The 8472-117/+251
2024-06-21std::unix::fs: copy simplification for apple.David Carlier-35/+15
since we do support from macOs Sierra, we avoid the little runtime overhead with the fclonefileat symbol check.
2024-06-21Remove `feature(effects)` from the standard libraryDeadbeef-1/+0
2024-06-21fix issue numberTristan Guichaoua-5/+5
2024-06-20Don't perform mitigation for thread-unsafe libc::exit under Miri.Zachary S-1/+9
1. Miri's exit is thread-safe 2. Miri doesn't (yet) support `libc::gettid`, used in the implementation of the mitigation on Linux.
2024-06-20fix rustdoc URLZachary S-3/+4
2024-06-20On `target_os = "linux"`, ensure that only one Rust thread calls ↵Zachary S-0/+93
`libc::exit` or returns from `main`.
2024-06-20Auto merge of #126736 - matthiaskrgr:rollup-rb20oe3, r=matthiaskrgrbors-12/+23
Rollup of 7 pull requests Successful merges: - #126380 (Add std Xtensa targets support) - #126636 (Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s ) - #126659 (More status-quo tests for the `#[coverage(..)]` attribute) - #126711 (Make Option::as_[mut_]slice const) - #126717 (Clean up some comments near `use` declarations) - #126719 (Fix assertion failure for some `Expect` diagnostics.) - #126730 (Add opaque type corner case test) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-20Stabilize `PanicInfo::message()` and `PanicMessage`StackOverflowExcept1on-1/+0
2024-06-19Stabilize `hint_assert_unchecked`Trevor Gross-1/+0
Make both `hint_assert_unchecked` and `const_hint_assert_unchecked` stable as `hint_assert_unchecked`.
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+9
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-20Convert some module-level `//` and `///` comments to `//!`.Nicholas Nethercote-12/+14
This makes their intent and expected location clearer. We see some examples where these comments were not clearly separate from `use` declarations, which made it hard to understand what the comment is describing.
2024-06-19Stabilise c_unwindGary Guo-1/+1
2024-06-18Replace `move||` with `move ||` in `compiler/` and `library/`Vonr-16/+16
Edit from #126631 to revert changes on ui tests
2024-06-17Add PanicMessage type for PanicInfo::message().Mara Bos-5/+8
2024-06-17std: rename module for clarityjoboet-2/+2
2024-06-17std: update TLS module documentationjoboet-16/+22
2024-06-17std: use the `c_int` from `core::ffi` instead of `libc`joboet-1/+1
2024-06-17std: simplify `#[cfg]`s for TLSjoboet-15/+10
2024-06-17Rollup merge of #126346 - hermit-os:fd, r=Amanieu许杰友 Jieyou Xu (Joe)-13/+4
export std::os::fd module on HermitOS The HermitOS' IO interface is similiar to Unix. Consequently, this PR synchronize the FD implementation between both. closes #126198
2024-06-16std: move `sys_common::backtrace` to `sys`joboet-10/+10
2024-06-16Rollup merge of #125112 - tbu-:pr_create_dir_all_empty, r=dtolnayJacob Pratt-0/+3
Document behavior of `create_dir_all` wrt. empty path The behavior makes sense because `Path::new("one_component").parent() == Some(Path::new(""))`, so if one naively wants to create the parent directory for a file to be written, it simply works. Closes #105108 by documenting the current behavior.
2024-06-15Rollup merge of #126229 - ChrisDenton:bindgen, r=Mark-SimulacrumGuillaume Gomez-417/+66
Bump windows-bindgen to 0.57 This PR updates our generated Windows API bindings using the latest version of `windows-bindgen`. The only change to the generated code is that `derive` is used for `Copy` and `Clone` instead of `impl`.
2024-06-15std: refactor the TLS implementationjoboet-927/+717
As discovered by Mara in #110897, our TLS implementation is a total mess. In the past months, I have simplified the actual macros and their expansions, but the majority of the complexity comes from the platform-specific support code needed to create keys and register destructors. In keeping with #117276, I have therefore moved all of the `thread_local_key`/`thread_local_dtor` modules to the `thread_local` module in `sys` and merged them into a new structure, so that future porters of `std` can simply mix-and-match the existing code instead of having to copy the same (bad) implementation everywhere. The new structure should become obvious when looking at `sys/thread_local/mod.rs`. Unfortunately, the documentation changes associated with the refactoring have made this PR rather large. That said, this contains no functional changes except for two small ones: * the key-based destructor fallback now, by virtue of sharing the implementation used by macOS and others, stores its list in a `#[thread_local]` static instead of in the key, eliminating one indirection layer and drastically simplifying its code. * I've switched over ZKVM (tier 3) to use the same implementation as WebAssembly, as the implementation was just a way worse version of that Please let me know if I can make this easier to review! I know these large PRs aren't optimal, but I couldn't think of any good intermediate steps. @rustbot label +A-thread-locals
2024-06-15Auto merge of #126518 - matthiaskrgr:rollup-wb70rzq, r=matthiaskrgrbors-28/+39
Rollup of 9 pull requests Successful merges: - #125829 (rustc_span: Add conveniences for working with span formats) - #126361 (Unify intrinsics body handling in StableMIR) - #126417 (Add `f16` and `f128` inline ASM support for `x86` and `x86-64`) - #126424 ( Also sort `crt-static` in `--print target-features` output) - #126428 (Polish `std::path::absolute` documentation.) - #126429 (Add `f16` and `f128` const eval for binary and unary operationations) - #126448 (End support for Python 3.8 in tidy) - #126488 (Use `std::path::absolute` in bootstrap) - #126511 (.mailmap: Associate both my work and my private email with me) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-15std: suggest OnceLock over OnceJubilee Young-4/+14
2024-06-14Polish `std::path::absolute` documentation.Kevin Reid-28/+39
These changes bring it closer to other standard library documentation and, in particular, `std::fs::canonicalize`, which it will often be compared with. * Add `# Platform-specific behavior` section, with content moved from Examples section. * Create `# Errors` section. * Phrase error description to allow future platforms to have new syntactic errors, rather than only emptiness. * Add missing commas. * Indent example code 4 spaces.
2024-06-14Auto merge of #126473 - matthiaskrgr:rollup-8w2xm09, r=matthiaskrgrbors-93/+184
Rollup of 7 pull requests Successful merges: - #123769 (Improve escaping of byte, byte str, and c str proc-macro literals) - #126054 (`E0229`: Suggest Moving Type Constraints to Type Parameter Declaration) - #126135 (add HermitOS support for vectored read/write operations) - #126266 (Unify guarantees about the default allocator) - #126285 (`UniqueRc`: support allocators and `T: ?Sized`.) - #126399 (extend the check for LLVM build) - #126426 (const validation: fix ICE on dangling ZST reference) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-14Rollup merge of #126266 - tbu-:pr_doc_alloc_default_system, r=jhprattMatthias Krüger-1/+3
Unify guarantees about the default allocator `std::alloc` said that the default allocator is unspecified for all crrate types except `cdylib` and `staticlib`. Adjust `std::alloc::System` documentation to say the same. Fixes #125870.
2024-06-14Rollup merge of #126135 - hermit-os:fuse, r=jhprattMatthias Krüger-92/+181
add HermitOS support for vectored read/write operations In general, the I/O interface of hermit-abi is revised and now a more POSIX-like interface. Consequently, platform abstraction layer for HermitOS has slightly adjusted and some inaccuracies remove. Hermit is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-06-14Rollup merge of #126351 - devnexen:to_sol11_upd, r=ChrisDentonMatthias Krüger-19/+2
std::unix::fs::link using direct linkat call for Solaris. Since we support solaris 11 as minimum, we can get rid of the runtime overhead. try-job: dist-various-2
2024-06-13Rollup merge of #123726 - jieyouxu:command-new-docs, r=NilstriebMatthias Krüger-0/+19
Clarify `Command::new` behavior for programs with arguments I mistakenly passed program path along arguments as the same string into `Command::new` a couple of times now. It might be useful to explicitly highlight that `Command::new` intends to accept path to a program, not path to a program plus arguments. Also nudge the user to use `Command::arg` or `Command::args` if they wish to pass arguments.
2024-06-13std::unix::fs::link using direct linkat call for Solaris and macOs.David Carlier-19/+2
Since we support solaris 11 and macOs Sierra as minimum, we can get rid of the runtime overhead.
2024-06-12export std::os::fd module on HermitOSStefan Lankes-13/+4
The HermitOS' IO interface is similiar to Unix. Consequently, this PR synchronize the FD implementation between both.
2024-06-12Auto merge of #126273 - pietroalbini:pa-bootstrap-update, r=Mark-Simulacrumbors-30/+14
Bump stage0 to 1.80.0 r? `@Mark-Simulacrum`
2024-06-12Rollup merge of #126322 - m-ou-se:panicinfo-and-panicinfo-2, r=RalfJungGuillaume Gomez-4/+1
Follow up to splitting core's PanicInfo and std's PanicInfo
2024-06-12Rollup merge of #126039 - dpaoliello:arm64ecbuild, r=davidtwcoGuillaume Gomez-1/+5
Promote `arm64ec-pc-windows-msvc` to tier 2 MCP: <https://github.com/rust-lang/compiler-team/issues/746> * Update platform support docs * Add `arm64ec-pc-windows-msvc` as a target to the existing AArch64 Windows build in CI. * Fix docs build break. * Add `arm64ec-pc-windows-msvc` to build manifest. CI build (succeeded, but upload to S3 failed): <https://github.com/rust-lang/rust/actions/runs/9388227822/job/25853013083?pr=126039>
2024-06-12Use payload_as_str instead of two downcasts.Mara Bos-4/+1
2024-06-12Auto merge of #126319 - workingjubilee:rollup-lendnud, r=workingjubileebors-6/+27
Rollup of 16 pull requests Successful merges: - #123374 (DOC: Add FFI example for slice::from_raw_parts()) - #124514 (Recommend to never display zero disambiguators when demangling v0 symbols) - #125978 (Cleanup: HIR ty lowering: Consolidate the places that do assoc item probing & access checking) - #125980 (Nvptx remove direct passmode) - #126187 (For E0277 suggest adding `Result` return type for function when using QuestionMark `?` in the body.) - #126210 (docs(core): make more const_ptr doctests assert instead of printing) - #126249 (Simplify `[T; N]::try_map` signature) - #126256 (Add {{target}} substitution to compiletest) - #126263 (Make issue-122805.rs big endian compatible) - #126281 (set_env: State the conclusion upfront) - #126286 (Make `storage-live.rs` robust against rustc internal changes.) - #126287 (Update a cranelift patch file for formatting changes.) - #126301 (Use `tidy` to sort crate attributes for all compiler crates.) - #126305 (Make PathBuf less Ok with adding UTF-16 then `into_string`) - #126310 (Migrate run make prefer rlib) - #126314 (fix RELEASES: we do not support upcasting to auto traits) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-12Rollup merge of #126305 - ↵Jubilee-0/+17
workingjubilee:fix-os-string-to-string-utf8-invariant, r=joboet Make PathBuf less Ok with adding UTF-16 then `into_string` Fixes #126291 which is, as far as I can tell, a regression introduced by #96869. try-job: x86_64-msvc
2024-06-12Rollup merge of #126287 - nnethercote:reformat-cranelift-patch, r=bjorn3Jubilee-2/+2
Update a cranelift patch file for formatting changes. PR #125443 will reformat all the use declarations in the repo. This would break a patch kept in `rustc_codegen_cranelift` that gets applied to `library/std/src/sys/pal/windows/rand.rs`. So this commit formats the use declarations in `library/std/src/sys/pal/windows/rand.rs` in advance of #125443 and updates the patch file accordingly. The motivation is that #125443 is a huge change and we want to get fiddly little changes like this out of the way so it can be nothing more than an `x fmt --all`. r? ``@bjorn3``
2024-06-12Rollup merge of #126281 - ChrisDenton:env, r=jhprattJubilee-4/+8
set_env: State the conclusion upfront People tend to skim or skip over long explanations so we should be very upfront that `set_var` and `remove_var` are being made unsafe for a very good reason. This is just the conclusion restated almost verbatim but earlier in the docs and separated from the explanation: https://github.com/rust-lang/rust/blob/0c960618b56f662d933e8b864cd9632a99174e87/library/std/src/env.rs#L338-L339 I think this may help with people who may not be entirely comfortable with #125937 being rejected.
2024-06-12Require any function with a tait in its signature to actually constrain a ↵Oli Scherer-28/+32
hidden type
2024-06-12Make PathBuf less Ok with adding UTF-16 then `into_string`Jubilee Young-0/+17
2024-06-12Update a cranelift patch file for formatting changes.Nicholas Nethercote-2/+2
PR #125443 will reformat all the use declarations in the repo. This would break a patch kept in `rustc_codegen_cranelift` that gets applied to `library/std/src/sys/pal/windows/rand.rs`. So this commit formats the use declarations in `library/std/src/sys/pal/windows/rand.rs` in advance of #125443 and updates the patch file accordingly. The motivation is that #125443 is a huge change and we want to get fiddly little changes like this out of the way so it can be nothing more than an `x fmt --all`.
2024-06-11set_env: State the conclusion upfrontChris Denton-4/+8
2024-06-11Rename `std::fs::try_exists` to `std::fs::exists` and stabilize fs_try_existsEduardo Sánchez Muñoz-19/+18