about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2024-07-15Rollup merge of #127750 - ChrisDenton:safe-unsafe-unsafe, r=workingjubileeJubilee-25/+51
Make os/windows and pal/windows default to `#![deny(unsafe_op_in_unsafe_fn)]` This is to prevent regressions in modules that currently pass. I did also fix up a few trivial places where the module contained only one or two simple wrappers. In more complex cases we should try to ensure the `unsafe` blocks are appropriately scoped and have any appropriate safety comments. This does not fix the windows bits of #127747 but it should help prevent regressions until that is done and also make it more obvious specifically which modules need attention.
2024-07-15Rollup merge of #127744 - workingjubilee:deny-unsafe-op-in-std, r=jhprattJubilee-66/+89
std: `#![deny(unsafe_op_in_unsafe_fn)]` in platform-independent code This applies the `unsafe_op_in_unsafe_fn` lint in all places in std that _do not have platform-specific cfg in their code_. For all such places, the lint remains allowed, because they need further work to address the relevant concerns. This list includes: - `std::backtrace_rs` (internal-only) - `std::sys` (internal-only) - `std::os` Notably this eliminates all "unwrapped" unsafe operations in `std::io` and `std::sync`, which will make them much more auditable in the future. Such has *also* been left for future work. While I made a few safety comments along the way on interfaces I have grown sufficiently familiar with, in most cases I had no context, nor particular confidence the unsafety was correct. In the cases where I was able to determine the unsafety was correct without having prior context, it was obviously redundant. For example, an unsafe function calling another unsafe function that has the exact same contract, forwarding its caller's requirements just as it forwards its actual call.
2024-07-15Rollup merge of #127712 - ChrisDenton:raw-types, r=workingjubileeJubilee-200/+166
Windows: Remove some unnecessary type aliases Back in the olden days, C did not have fixed-width types so these type aliases were at least potentially useful. Nowadays, and especially in Rust, we don't need the aliases and they don't help with anything. Notably the windows bindings we use also don't bother with the aliases. And even when we have used aliases they're often only used once then forgotten about. The only one that gives me pause is `DWORD` because it's used a fair bit. But it's still used inconsistently and we implicitly assume it's a `u32` anyway (e.g. `as` casting from an `i32`).
2024-07-15Move safety comment outside unsafe blockChris Denton-1/+1
2024-07-15Make os/windows default to deny unsafe in unsafeChris Denton-15/+26
2024-07-15Make pal/windows default to deny unsafe in unsafeChris Denton-11/+26
2024-07-15Fix Windows 7Chris Denton-4/+4
2024-07-15Auto merge of #127719 - devnexen:math_log_fix_solill, r=Amanieubors-34/+3
std: removes logarithms family function edge cases handling for solaris. Issue had been fixed over time with solaris, 11.x behaves correctly (and we support it as minimum), illumos works correctly too.
2024-07-15Don't re-export `c_int` from `c`Chris Denton-8/+7
2024-07-15Remove DWORDChris Denton-105/+90
2024-07-15Remove ULONGChris Denton-14/+13
2024-07-15Remove PSRWLOCKChris Denton-4/+1
2024-07-15Remove LPVOIDChris Denton-18/+18
2024-07-15Remove LPSECURITY_ATTRIBUTESChris Denton-3/+2
2024-07-15Remove LPOVERLAPPEDChris Denton-2/+1
2024-07-15Remove LPCVOIDChris Denton-2/+1
2024-07-15Remove SIZE_TChris Denton-3/+2
2024-07-15Remove CHARChris Denton-4/+3
As with USHORT, keep using C types for BSD socket APIs.
2024-07-15Remove USHORTChris Denton-4/+3
We stick to C types in for socket and address as these are at least nominally BSD-ish and they're used outside of pal/windows in general *nix code
2024-07-15Remove LPWSTRChris Denton-10/+8
2024-07-15Remove UINTChris Denton-2/+1
2024-07-15Remove LONGChris Denton-4/+2
2024-07-15Remove LARGE_INTEGERChris Denton-16/+15
2024-07-15Remove NonZeroDWORDChris Denton-5/+3
2024-07-15Auto merge of #127732 - GrigorenkoPV:teeos-safe-sys-init, r=Amanieubors-5/+6
sys::init is not unsafe on teeos https://github.com/rust-lang/rust/blob/88fa119c77682e6d55ce21001cf761675cfebeae/library/std/src/sys/pal/teeos/mod.rs#L40-L42 r​? `@petrochenkov`
2024-07-14std: Unsafe-wrap std::syncJubilee Young-41/+54
2024-07-14std: Unsafe-wrap in Wtf8 implJubilee Young-5/+10
2024-07-14std: Unsafe-wrap std::ioJubilee Young-9/+13
2024-07-14std: Directly call unsafe {un,}setenv in envJubilee Young-11/+4
2024-07-14std: Unsafe-wrap OSStr{,ing}::from_encoded_bytes_uncheckedJubilee Young-3/+2
2024-07-14std: Unsafe-wrap HashMap::get_many_unchecked_mutJubilee Young-3/+1
2024-07-14std: deny(unsafe_op_in_unsafe_fn) but allow sitesJubilee Young-1/+12
This provides a list of locations to hunt down issues in.
2024-07-14Add `classify` and related methods for `f16` and `f128`Trevor Gross-38/+94
2024-07-14std: removes logarithms family function edge cases handling for solaris.David Carlier-34/+3
Issue had been fixed over time with solaris, 11.x behaves correctly (and we support it as minimum), illumos works correctly too.
2024-07-14sys::init is not unsafe on teeosPavel Grigorenko-5/+6
2024-07-14Auto merge of #125935 - madsmtm:merge-os-apple, r=workingjubileebors-797/+86
Merge Apple `std::os` extensions modules into `std::os::darwin` The functionality available on Apple platforms are very similar, and were (basically) duplicated for each platform. This PR rectifies that by merging the code into one module. Ultimately, I've done this to fix `./x build library --target=aarch64-apple-tvos,aarch64-apple-watchos,aarch64-apple-visionos`, as that currently fails because of dead code warnings. Publically exposing these to tvOS/watchOS/visionOS targets is considered in https://github.com/rust-lang/rust/pull/123723, but that seems to be dragging out, and in any case I think it makes sense to do the refactor separately from stabilization. r? libs Fixes https://github.com/rust-lang/rust/issues/121640 and https://github.com/rust-lang/rust/issues/124825.
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