about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-07-14Merge Apple `std::os` extensions modules into `std::os::darwin`Mads Marquart-797/+86
The functionality available on Apple platforms are very similar, and were duplicated for each platform. Additionally, this fixes a warning when compiling the standard library for tvOS, watchOS and visionOS by marking the corresponding code as dead code.
2024-07-14Rollup merge of #127704 - workingjubilee:fixup-better-than, r=ChrisDentonMatthias Krüger-2/+2
Fix minor typos in std::process doc on Win argv
2024-07-14Auto merge of #127706 - workingjubilee:rollup-d07ij30, r=workingjubileebors-7/+17
Rollup of 6 pull requests Successful merges: - #122300 (Add FileCheck annotations to mir-opt/dest-prop tests) - #127434 (use "bootstrap" instead of "rustbuild" in comments and docs) - #127477 (Clear `inner_attr_ranges` regularly.) - #127558 (More attribute cleanups) - #127659 (Use ManuallyDrop in BufWriter::into_parts) - #127671 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 8)) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-13Rollup merge of #127659 - saethlin:manually-drop-bufwriter, r=joboetJubilee-7/+17
Use ManuallyDrop in BufWriter::into_parts The fact that `mem::forget` takes by value means that it interacts very poorly with Stacked Borrows; generally users think of calling it as a no-op, but in Stacked Borrows, the field retagging tends to cause surprise tag invalidation.
2024-07-13Rollup merge of #127446 - zachs18:miri-stdlib-leaks-core-alloc, ↵Jubilee-0/+3
r=Mark-Simulacrum Remove memory leaks in doctests in `core`, `alloc`, and `std` cc `@RalfJung` https://github.com/rust-lang/rust/issues/126067 https://github.com/rust-lang/miri/issues/3670 Should be no actual *documentation* changes[^1], all added/modified lines in the doctests are hidden with `#`, This PR splits the existing memory leaks in doctests in `core`, `alloc`, and `std` into two general categories: 1. "Non-focused" memory leaks that are incidental to the thing being documented, and/or are easy to remove, i.e. they are only there because preventing the leak would make the doctest less clear and/or concise. - These doctests simply have a comment like `# // Prevent leaks for Miri.` above the added line that removes the memory leak. - [^2]Some of these would perhaps be better as part of the public documentation part of the doctest, to clarify that a memory leak can happen if it is not otherwise mentioned explicitly in the documentation (specifically the ones in `(A)Rc::increment_strong_count(_in)`). 2. "Focused" memory leaks that are intentional and documented, and/or are possibly fragile to remove. - These doctests have a `# // FIXME` comment above the line that removes the memory leak, with a note that once `-Zmiri-disable-leak-check` can be applied at test granularity, these tests should be "un-unleakified" and have `-Zmiri-disable-leak-check` enabled. - Some of these are possibly fragile (e.g. unleaking the result of `Vec::leak`) and thus should definitely not be made part of the documentation. This should be all of the leaks currently in `core` and `alloc`. I only found one leak in `std`, and it was in the first category (excluding the modules `@RalfJung` mentioned in https://github.com/rust-lang/rust/issues/126067 , and reducing the number of iterations of [one test](https://github.com/rust-lang/rust/blob/master/library/std/src/sync/once_lock.rs#L49-L94) from 1000 to 10) [^1]: assuming [^2] is not added [^2]: backlink
2024-07-13Rollup merge of #127370 - ChrisDenton:win-sys, r=Mark-SimulacrumJubilee-67/+77
Windows: Add experimental support for linking std-required system DLLs using raw-dylib For Windows, this allows std to define system imports without needing the user to have import libraries. It's intended for this to become the default. For now it's an experimental feature so it can be tested using build-std.
2024-07-13Fix minor typos in std::process doc on Win argvJubilee Young-2/+2
2024-07-13std::unix::fs: removing, now useless, layers predating macOs 10.10.David Carlier-59/+1
fdopendir, openat and unlinkat are available since yosemite but we support sierra as minimum.
2024-07-13Auto merge of #127674 - jhpratt:rollup-0dxy3k7, r=jhprattbors-12/+4
Rollup of 3 pull requests Successful merges: - #127654 (Fix incorrect NDEBUG handling in LLVM bindings) - #127661 (Stabilize io_slice_advance) - #127668 (Improved slice documentation) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-13Rollup merge of #127661 - eduardosm:stabilize-io_slice_advance, r=cuviperJacob Pratt-12/+4
Stabilize io_slice_advance Closes https://github.com/rust-lang/rust/issues/62726 (FCP completed) Stabilized API: ```rust impl<'a> IoSlice<'a> { pub fn advance(&mut self, n: usize); pub fn advance_slices(bufs: &mut &mut [IoSlice<'a>], n: usize); } impl<'a> IoSliceMut<'a> { pub fn advance(&mut self, n: usize); pub fn advance_slices(bufs: &mut &mut [IoSliceMut<'a>], n: usize); } ```
2024-07-13Auto merge of #127397 - jyn514:multi-thread-panic-hook, r=workingjubileebors-30/+31
fix interleaved output in the default panic hook when multiple threads panic simultaneously previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook from one thread would be interleaved with the backtrace from another. now, we hold the lock for the full duration of the hook, and the output is ordered. --- i noticed some odd things while working on this you may or may not already be aware of. - libbacktrace is included as a submodule instead of a normal rustc crate, and as a result uses `cfg(backtrace_in_std)` instead of a more normal `cfg(feature = "rustc-dep-of-std")`. probably this is left over from before rust used a cargo-based build system? - the default panic handler uses `trace_unsynchronized`, etc, in `sys::backtrace::print`. as a result, the lock only applies to concurrent *panic handlers*, not concurrent *threads*. in other words, if another, non-panicking, thread tried to print a backtrace at the same time as the panic handler, we may have UB, especially on windows. - we have the option of changing backtrace to enable locking when `backtrace_in_std` is set so we can reuse their lock instead of trying to add our own.
2024-07-13Auto merge of #126606 - zachs18:patch-2, r=joboetbors-0/+77
Guard against calling `libc::exit` multiple times on Linux. Mitigates (but does not fix) #126600 by ensuring only one thread which calls Rust `exit` actually calls `libc::exit`, and all other callers of Rust `exit` block.
2024-07-12Use ManuallyDrop in BufWriter::into_partsBen Kimock-7/+17
2024-07-12Stabilize io_slice_advanceEduardo Sánchez Muñoz-12/+4
2024-07-12fix interleaved panic outputjyn-30/+31
previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook would be interleaved with the backtrace. now, we hold the lock for the full duration of the hook, and the output is ordered.
2024-07-12Rollup merge of #126827 - the8472:pidfd-spawn, r=workingjubileeMatthias Krüger-6/+131
Use pidfd_spawn for faster process spawning when a PidFd is requested glibc 2.39 added `pidfd_spawnp` and `pidfd_getpid` which makes it possible to get pidfds while staying on the CLONE_VFORK path. verified that vfork gets used with strace: ``` $ strace -ff -e pidfd_open,clone3,openat,execve,waitid,close ./x test std --no-doc -- pidfd [...] [pid 2820532] clone3({flags=CLONE_VM|CLONE_PIDFD|CLONE_VFORK|CLONE_CLEAR_SIGHAND, pidfd=0x7b7f885fec6c, exit_signal=SIGCHLD, stack=0x7b7f88aff000, stack_size=0x9000}strace: Process 2820533 attached <unfinished ...> [pid 2820533] execve("/home/the8472/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/home/the8472/.cargo/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/usr/local/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */) = -1 ENOENT (No such file or directory) [pid 2820533] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffdd0e268d8 /* 107 vars */ <unfinished ...> [pid 2820532] <... clone3 resumed> => {pidfd=[3]}, 88) = 2820533 [pid 2820533] <... execve resumed>) = 0 [pid 2820532] openat(AT_FDCWD, "/proc/self/fdinfo/3", O_RDONLY|O_CLOEXEC) = 4 [pid 2820532] close(4) = 0 ``` Tracking issue: #82971
2024-07-11[library/std/src/process.rs] `PartialEq` & `Eq` for `ExitCode`Samuel Marks-1/+1
2024-07-11Rollup merge of #127599 - tgross35:lazy_cell_consume-rename, r=workingjubileeMatthias Krüger-2/+2
Rename `lazy_cell_consume` to `lazy_cell_into_inner` Name this something that is less confusable with an atomic consume API for `{Lazy,Once}Lock`.
2024-07-11Rename `lazy_cell_consume` to `lazy_cell_into_inner`Trevor Gross-2/+2
Name this something that is less confusable with an atomic consume API for `{Lazy,Once}Lock`.
2024-07-10Explicitly ignore `into_raw_handle()` using `let _ =` in sys/pal/windows.Zachary S-3/+3
2024-07-10Add `must_use` to IntoRawFd/IntoRawSocket/IntoRawHandle's methods.Zachary S-0/+4
2024-07-10Don't mark `DEBUG_EVENT` struct as `repr(packed)`Tobias Bucher-1/+1
That would give it alignment of 1 which is ABI-incompatible with its C definition.
2024-07-09Fixed doc linksAndres Olivares-2/+2
2024-07-09Few changes to doc comments. Added tracking issue number.Andres Olivares-4/+5
2024-07-09Exposing STARTUPINFOW.wShowWindow in CommandExt (show_window function) to ↵Andres Olivares-0/+22
control how a new process should display its window (normal, minimized, maximized, etc)
2024-07-08Rollup merge of #127460 - Borgerr:clarify-drop-comment, r=jhprattMatthias Krüger-0/+5
clarify `sys::unix::fd::FileDesc::drop` comment closes #66876 simply clarifies some resource-relevant things regarding the `close` syscall to reduce the amount of search needed in other parts of the web.
2024-07-08Attempt to fix CIzachs18-3/+12
2024-07-08Reset sigpipe not supported for vxworksB I Mohammed Abbas-0/+1
2024-07-07Move/change declaration of `mod exit_guard;`zachs18-1/+1
2024-07-07clarify `sys::unix::fd::FileDesc::drop` comment (#66876)Ashton Hunt-0/+5
2024-07-07Rollup merge of #127447 - RalfJung:once_lock_miri, r=joboetMatthias Krüger-6/+13
once_lock: make test not take as long in Miri Allocating 1000 list elements takes a while (`@zachs18` reported >5min), so let's reduce the iteration count when running in Miri. Unfortunately due to this clever `while let i @ 0..LEN =` thing, the count needs to be a constants, and constants cannot be shadowed, so we need to use another trick to hide the `cfg!(miri)` from the docs. (I think this loop condition may be a bit too clever, it took me a bit to decipher. Ideally this would be `while let i = ... && i < LEN`, but that is not stable yet.)
2024-07-07Rollup merge of #127297 - the8472:path-new-hash, r=NilstriebMatthias Krüger-4/+44
Improve std::Path's Hash quality by avoiding prefix collisions This adds a bit rotation to the already existing state so that the same sequence of characters chunked at different offsets into separate path components results in different hashes. The tests are from #127255 Closes #127254
2024-07-07once_lock: make test not take as long in MiriRalf Jung-6/+13
2024-07-06Remove non-focused memory leak in `std` doctest for Miri.Zachary S-0/+3
2024-07-05Rollup merge of #123600 - tisonkun:path_with_extension, r=dtolnayMichael Goulet-0/+168
impl PathBuf::add_extension and Path::with_added_extension See the ACP for motivation and discussions - https://github.com/rust-lang/libs-team/issues/368
2024-07-05Attempt to fix CIZachary S-0/+2
2024-07-05Move exit guard from sys::common::exit_guard to sys::exit_guard.Zachary S-4/+3
2024-07-05Update library/std/src/sys/pal/common/exit_guard.rszachs18-3/+5
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-07-05add unit tests for extra extension featuretison-0/+74
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05update commentstison-4/+1
Signed-off-by: tison <wander4096@gmail.com>
2024-07-05Add experimental raw-dylib feature to stdChris Denton-0/+13
For Windows, this allows defining imports without needing the user to have import libraries. It's intended for this to become the default.
2024-07-05Use windows_targets macro for allocChris Denton-67/+64
2024-07-05Rollup merge of #127320 - ChrisDenton:win-sys, r=Mark-SimulacrumGuillaume Gomez-851/+162
Update windows-bindgen to 0.58.0 This also switches from the bespoke `std` generated bindings to the normal `sys` ones everyone else uses. This has almost no difference except that the `sys` bindings use the `windows_targets::links!` macro for FFI imports, which we implement manually. This does cause the diff to look much larger than it really is but the bulk of the changes are mostly contained to the generated code.
2024-07-04Add comments to windows_targets.rsChris Denton-0/+9
2024-07-04Update windows-bindgen to 0.58.0Chris Denton-851/+153
2024-07-04Rollup merge of #127195 - biabbas:vxworks_cleanup, r=jhprattJacob Pratt-2/+4
Remove unqualified form import of io::Error in process_vxworks.rs and fallback on remove_dir_impl for vxworks Hi all, This is to address issue #127084. On inspections it was found that io::Error refrences were all of qualified form and there was no need to add a unqualified form import. Also to successfully build rust for vxworks, we need to fallback on the remove_impl_dir implementations. Thank you.
2024-07-04Rollup merge of #126792 - wooden-worm:master, r=Mark-SimulacrumJacob Pratt-10/+16
wasm64 build with target-feature=+simd128,+atomics Fixes https://github.com/rust-lang/rust/issues/126778
2024-07-03impl PathBuf::add_extension and Path::with_added_extensiontison-0/+97
Signed-off-by: tison <wander4096@gmail.com>
2024-07-04stir the hash state a little to avoid prefix collisionsThe 8472-4/+9
2024-07-03Add more test cases for path comparisonsZanie Blue-0/+28