about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-04-26Add functions to un-poison Mutex and RwLockThayne McCombs-0/+73
See discussion at https://internals.rust-lang.org/t/unpoisoning-a-mutex/16521/3
2022-04-26Retry deleting a directoryChris Denton-2/+15
It's possible that a file in the directory is pending deletion. In that case we might succeed after a few attempts.
2022-04-25Remove references to git.ioEric Huss-1/+2
2022-04-26Windows: Iterative `remove_dir_all`Chris Denton-77/+67
This will allow better strategies for use of memory and File handles. However, fully taking advantage of that is left to future work.
2022-04-25Make EncodeWide implement FusedIteratorAron Parker-1/+4
2022-04-25std: directly use pthread in UNIX parker implementationjoboet-28/+372
Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore use the pthread synchronization primitives directly. Also, avoid allocating because the Parker struct is being placed in an Arc anyways.
2022-04-25Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplettbors-91/+212
Windows Command: Don't run batch files using verbatim paths Fixes #95178 Note that the first commit does some minor refactoring (moving command line argument building to args.rs). The actual changes are in the second.
2022-04-24Auto merge of #94609 - esp-rs:esp-idf-stat-type-fixes, r=Mark-Simulacrumbors-15/+30
espidf: fix stat Marking as draft as currently dependant on [a libc fix](https://github.com/rust-lang/libc/pull/2708) and release.
2022-04-23std: `<ExitStatus as Display>::fmt` name the signal it died fromMichael Howell-3/+66
2022-04-23Use const initializer for LOCAL_PANIC_COUNTbjorn3-1/+1
This reduces the size of the __getit function for LOCAL_PANIC_COUNT and should speed up accesses of LOCAL_PANIC_COUNT a bit.
2022-04-23Auto merge of #96314 - AronParker:issue-96297-fix, r=thomccbors-1/+7
Reduce allocations for path conversions on Windows Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-23Auto merge of #94887 - dylni:move-normpath-crate-impl-to-libstd, r=ChrisDentonbors-57/+142
Improve Windows path prefix parsing This PR fixes improves parsing of Windows path prefixes. `parse_prefix` now supports both types of separators on Windows (`/` and `\`).
2022-04-22Remove redundant type annotationAron Parker-1/+1
2022-04-22Reduce allocations for path conversions on WindowsAron Parker-1/+7
Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-21Rollup merge of #96193 - djkoloski:fuchsia_current_exe, r=tmandryDylan DPC-1/+21
[fuchsia] Add implementation for `current_exe` This implementation returns a best attempt at the current exe path. On fuchsia, fdio will always use `argv[0]` as the process name and if it is not set then an error will be returned. Because this is not guaranteed to be the case, this implementation returns an error if `argv` does not contain any elements.
2022-04-20Rollup merge of #96234 - goffrie:eloop, r=thomccDylan DPC-1/+2
remove_dir_all_recursive: treat ELOOP the same as ENOTDIR On older Linux kernels (I tested on 4.4, corresponding to Ubuntu 16.04), opening a symlink using `O_DIRECTORY | O_NOFOLLOW` returns `ELOOP` instead of `ENOTDIR`. We should handle it the same, since a symlink is still not a directory and needs to be `unlink`ed.
2022-04-20Rollup merge of #96206 - m-ou-se:wasm-futex-locks, r=alexcrichtonDylan DPC-358/+24
Use sys::unix::locks::futex* on wasm+atomics. This removes the wasm-specific lock implementations and instead re-uses the implementations from sys::unix. Tracking issue: https://github.com/rust-lang/rust/issues/93740 cc ``@alexcrichton``
2022-04-20Rollup merge of #96168 - ↵Dylan DPC-11/+28
chris-morgan:AddrParseError-description-improvements, r=joshtriplett Improve AddrParseError description The existing description was incorrect for socket addresses, and misleading: users would see “invalid IP address syntax” and suppose they were supposed to provide an IP address rather than a socket address. I contemplated making it two variants (IP, socket), but realised we can do still better for the IPv4 and IPv6 types, so here it is as six. I contemplated more precise error descriptions (e.g. “invalid IPv6 socket address syntax: expected a decimal scope ID after %”), but that’s a more invasive change, and probably not worthwhile anyway.
2022-04-20Rollup merge of #96167 - CAD97:weak-dlsym-less-ptr-crime, r=thomccDylan DPC-17/+15
Replace sys/unix/weak AtomicUsize with AtomicPtr Should fix #96163. Can't easily test on Windows though...
2022-04-20remove_dir_all_recursive: treat ELOOP the same as ENOTDIRGeoffry Song-1/+2
2022-04-19Make `BorrowedFd::borrow_raw` a const fn.Dan Gohman-5/+5
Making `BorrowedFd::borrow_raw` a const fn allows it to be used to create a constant `BorrowedFd<'static>` holding constants such as `AT_FDCWD`. This will allow [`rustix::fs::cwd`] to become a const fn. For consistency, make similar changes to `BorrowedHandle::borrow_raw` and `BorrowedSocket::borrow_raw`. [`rustix::fs::cwd`]: https://docs.rs/rustix/latest/rustix/fs/fn.cwd.html
2022-04-19[fuchsia] Add implementation for `current_exe`David Koloski-1/+21
This implementation returns a best attempt at the current exe path. On fuchsia, fdio will always use `argv[0]` as the process name and if it is not set then an error will be returned. Because this is not guaranteed to be the case, this implementation returns an error if `argv` does not contain any elements.
2022-04-19espidf: fix statScott Mabin-15/+30
* corect type usage with new type definitions in libc
2022-04-19Use futex locks on emscripten.Mara Bos-0/+1
2022-04-19Use futex locks on wasm+atomics.Mara Bos-354/+6
2022-04-19Make std::sys::wasm::futex consistent with unix::futex.Mara Bos-4/+18
2022-04-19Make std::sys::unix::futex consistent on emscripten.Mara Bos-22/+25
2022-04-19Improve AddrParseError descriptionChris Morgan-11/+28
The existing description was incorrect for socket addresses, and misleading: users would see “invalid IP address syntax” and suppose they were supposed to provide an IP address rather than a socket address. I contemplated making it two variants (IP, socket), but realised we can do still better for the IPv4 and IPv6 types, so here it is as six. I contemplated more precise error descriptions (e.g. “invalid IPv6 socket address syntax: expected a decimal scope ID after %”), but that’s a more invasive change, and probably not worthwhile anyway.
2022-04-18Add a comment explaining the `(())` idiom for empty structs.Dan Gohman-0/+2
2022-04-18Split `NotHandle` into `NullHandleError` and `InvalidHandleError`.Dan Gohman-14/+31
Also, make the display messages more specific, and remove the `Copy` implementation.
2022-04-18Move the `Error` impl for `NotHandle` out of platform-independent code.Dan Gohman-0/+3
2022-04-18Fix an incorrect word in a comment.Dan Gohman-2/+2
2022-04-18Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`.Dan Gohman-6/+20
Define a `NotHandle` type, that implements `std::error::Error`, and use it as the error type in `HandleOrNull` and `HandleOrInvalid`.
2022-04-18Auto merge of #96042 - m-ou-se:one-reentrant-mutex, r=Amanieubors-541/+92
Use a single ReentrantMutex implementation on all platforms. This replaces all platform specific ReentrantMutex implementations by the one I added in #95727 for Linux, since that one does not depend on any platform specific details. r? `@Amanieu`
2022-04-18Remove forgotten reexport of ReentrantMutex in sys::unsupported.Mara Bos-1/+1
2022-04-17Replace sys/unix/weak AtomicUsize with AtomicPtrCAD97-17/+15
2022-04-17Auto merge of #93530 - anonion0:pthread_sigmask_fix, r=JohnTitorbors-4/+5
fix error handling for pthread_sigmask(3) Errors from `pthread_sigmask(3)` were handled using `cvt()`, which expects a return value of `-1` on error and uses `errno`. However, `pthread_sigmask(3)` returns `0` on success and an error number otherwise. Fix it by replacing `cvt()` with `cvt_nz()`.
2022-04-17move import to fix warning with emscripten targetRalf Sager-1/+2
2022-04-17Revert "Auto merge of #94373 - erikdesjardins:getitinl, r=Mark-Simulacrum"Erik Desjardins-2/+2
This reverts commit 035a717ee8bf548868fb50b5c7ca562fc4a657a7, reversing changes made to 761e8884858759b21f3374ad610494e68c087a38.
2022-04-17Remove unnecessary functiondylni-20/+18
2022-04-17Improve Windows path prefix parsingdylni-37/+124
2022-04-16Document rounding for floating-point primitive operationsMatthew Woodcraft-0/+13
State that the four primitive operations honour IEEE 754 roundTiesToEven. Documenting under "Primitive Type f32"; f64 refers to that.
2022-04-16Use a single ReentrantMutex implementation on all platforms.Mara Bos-540/+91
2022-04-15Rollup merge of #96040 - m-ou-se:futex-u32, r=AmanieuDylan DPC-53/+55
Use u32 instead of i32 for futexes. This changes futexes from i32 to u32. The [Linux man page](https://man7.org/linux/man-pages/man2/futex.2.html) uses `uint32_t` for them, so I'm not sure why I used i32 for them. Maybe because I first used them for thread parkers, where I used -1, 0, and 1 as the states. (Wasm's `memory.atomic.wait32` does use `i32`, because wasm doesn't support `u32`.) It doesn't matter much, but using the unsigned type probably results in fewer surprises when shifting bits around or using comparison operators. r? ```@Amanieu```
2022-04-15Rollup merge of #94461 - jhpratt:2024-edition, r=pnkfelixDylan DPC-0/+15
Create (unstable) 2024 edition [On Zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Deprecating.20macro.20scoping.20shenanigans/near/272860652), there was a small aside regarding creating the 2024 edition now as opposed to later. There was a reasonable amount of support and no stated opposition. This change creates the 2024 edition in the compiler and creates a prelude for the 2024 edition. There is no current difference between the 2021 and 2024 editions. Cargo and other tools will need to be updated separately, as it's not in the same repository. This change permits the vast majority of work towards the next edition to proceed _now_ instead of waiting until 2024. For sanity purposes, I've merged the "hello" UI tests into a single file with multiple revisions. Otherwise we'd end up with a file per edition, despite them being essentially identical. ````@rustbot```` label +T-lang +S-waiting-on-review Not sure on the relevant team, to be honest.
2022-04-15Auto merge of #94079 - petrochenkov:cstr, r=joshtriplettbors-1965/+67
library: Move `CStr` to libcore, and `CString` to liballoc Closes https://github.com/rust-lang/rust/issues/46736 Interesting points: - Stability: - To make `CStr(ing)` from libcore/liballoc unusable without enabling features I had to make these structures unstable, and reexport them from libstd using stable type aliases instead of `pub use` reexports. (Because stability of `use` items is not checked.) - Relying on target ABI in libcore is ok: - https://github.com/rust-lang/rust/pull/94079#issuecomment-1044263371 - `trait CStrExt` (UPDATE: used only in `cfg(bootstrap)` mode, otherwise lang items are used instead) - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450 - `strlen` - https://github.com/rust-lang/rust/pull/94079#issuecomment-1047863450 Otherwise it's just a code move + some minor hackery usual for liballoc in `cfg(test)` mode.
2022-04-15Auto merge of #95841 - ChrisDenton:pipe-server, r=m-ou-sebors-1/+50
Windows: Use a pipe relay for chaining pipes Fixes #95759 This fixes the issue by chaining pipes synchronously and manually pumping messages between them. It's not ideal but it has the advantage of not costing anything if pipes are not chained ("don't pay for what you don't use") and it also avoids breaking existing code that rely on our end of the pipe being asynchronous (which includes rustc's own testing framework). Libraries can avoid needing this by using their own pipes to chain commands.
2022-04-14library: Remove definitions and reexports of `strlen` from libstdVadim Petrochenkov-40/+0
2022-04-14library: Use type aliases to make `CStr(ing)` in libcore/liballoc unstableVadim Petrochenkov-4/+16
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-1925/+55