about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-05-01Fix formattingAustin Kiekintveld-2/+6
2022-05-01Relax memory ordering used in SameMutexCheckAustin Kiekintveld-1/+1
`SameMutexCheck` only requires atomicity for `self.addr`, but does not need ordering of other memory accesses in either the success or failure case. Using `Relaxed`, the code still correctly handles the case when two threads race to store an address.
2022-05-01Relax memory ordering used in `min_stack`Austin Kiekintveld-2/+2
`min_stack` does not provide any synchronization guarantees to its callers, and only requires atomicity for `MIN` itself, so relaxed memory ordering is sufficient.
2022-05-01Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomezbors-0/+7
rustdoc: Resolve doc links referring to `macro_rules` items cc https://github.com/rust-lang/rust/issues/81633 UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.
2022-05-01Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrumbors-6/+6
Make [e]println macros eagerly drop temporaries (for backport) This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434. My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61. argument position | before #94868 | after #94868 | after this PR --- |:---:|:---:|:---: `write!($tmp, "…", …)` | :rage: | :rage: | :rage: `write!(…, "…", $tmp)` | :rage: | :rage: | :rage: `writeln!($tmp, "…", …)` | :rage: | :rage: | :rage: `writeln!(…, "…", $tmp)` | :rage: | :rage: | :rage: `print!("…", $tmp)` | :rage: | :rage: | :rage: `println!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `eprint!("…", $tmp)` | :rage: | :rage: | :rage: `eprintln!("…", $tmp)` | :smiley_cat: | :rage: | :smiley_cat: `panic!("…", $tmp)` | :smiley_cat: | :smiley_cat: | :smiley_cat:
2022-05-01Fix some links in the standard libraryVadim Petrochenkov-0/+7
2022-04-30add aliases for std::fs::canonicalizejulio-0/+2
2022-04-29Disable pthread thread parker on futex platforms.Mara Bos-1/+5
2022-04-29Always return false in futex_wake on {Free,DragonFly}BSD.Mara Bos-16/+13
2022-04-29Use futex-based locks and thread parker on FreeBSD.Mara Bos-4/+60
2022-04-29Use futex-based locks and thread parker on DragonFlyBSD.Mara Bos-1/+44
2022-04-29Use futex-based locks and thread parker on NetBSD.Mara Bos-24/+53
2022-04-29Use futex-based locks and thread parker on OpenBSD.Mara Bos-1/+53
2022-04-29Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahcDylan DPC-10/+0
Revert "Re-export core::ffi types from std::ffi" This reverts commit 9aed829fe6cdf5eaf278c6c3972f7acd0830887d. Fixes https://github.com/rust-lang/rust/issues/96435 , a regression in crates doing `use std::ffi::*;` and `use std::os::raw::*;`. We can re-add this re-export once the `core::ffi` types are stable, and thus the `std::os::raw` types can become re-exports as well, which will avoid the conflict. (Type aliases to the same type still conflict, but re-exports of the same type don't.)
2022-04-29Rollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplettDylan DPC-1/+1
HashMap doc: Don't use monospace font for 'Entry Api'
2022-04-29Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-sebors-31/+119
Windows: Make stdin pipes synchronous Stdin pipes do not need to be used asynchronously within the standard library. This is a first step in making pipes mostly synchronous. r? `@m-ou-se`
2022-04-28Auto merge of #96393 - joboet:pthread_parker, r=thomccbors-30/+336
std: directly use pthread in UNIX parker implementation `Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways. This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives. I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.
2022-04-28Add more diagnostic itemsSerial-0/+1
2022-04-28Yield the thread when waiting to delete a fileChris Denton-0/+3
2022-04-28std: simplify UNIX parker timeoutsjoboet-59/+21
2022-04-28Rollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnayDylan DPC-1/+4
Make EncodeWide implement FusedIterator [`EncodeUtf16`](https://doc.rust-lang.org/std/str/struct.EncodeUtf16.html) and [`EncodeWide`](https://doc.rust-lang.org/std/os/windows/ffi/struct.EncodeWide.html) currently serve similar purposes: They convert from UTF-8 to UTF-16 and WTF-8 to WTF-16, respectively. `EncodeUtf16` wraps a &str, whereas `EncodeWide` wraps an &OsStr. When Iteration has concluded, these iterators wrap an empty slice, which will forever yield `None` values. Hence, `EncodeUtf16` rightfully implements `FusedIterator`. However, `EncodeWide` in contrast does not, even though it serves an almost identical purpose. This PR attempts to fix that issue. I consider this change minor and non-controversial, hence why I have not added a RFC/FCP. Please let me know if the stability attribute is wrong or contains a wrong version number. Thanks in advance. Fixes https://github.com/rust-lang/rust/issues/96368
2022-04-27Revert "Re-export core::ffi types from std::ffi"Josh Triplett-10/+0
This reverts commit 9aed829fe6cdf5eaf278c6c3972f7acd0830887d. Fixes https://github.com/rust-lang/rust/issues/96435 , a regression in crates doing `use std::ffi::*;` and `use std::os::raw::*;`. We can re-add this re-export once the `core::ffi` types are stable, and thus the `std::os::raw` types can become re-exports as well, which will avoid the conflict. (Type aliases to the same type still conflict, but re-exports of the same type don't.)
2022-04-27Make [e]println macros eagerly drop temporaries (for backport)David Tolnay-6/+6
2022-04-27HashMap doc: Don't use monospace font for 'Entry Api'Nixon Enraght-Moony-1/+1
2022-04-27Note the importance of using sync pipesChris Denton-1/+19
2022-04-27Add tracking issue number for mutex_unpoisonThayne McCombs-2/+2
2022-04-27Auto merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type, ↵bors-8/+44
r=joshtriplett Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`. Define `NullHandleError` and `InvalidHandleError` types, that implement std::error::Error, and use them as the error types in `HandleOrNull` and `HandleOrInvalid`, This addresses [this concern](https://github.com/rust-lang/rust/issues/87074#issuecomment-1080031167). This is the same as #95387. r? `@joshtriplett`
2022-04-26Windows: Make stdin pipes synchronousChris Denton-31/+85
Stdin pipes do not need to be used asynchronously within the standard library.
2022-04-26Add `set_inheritable` for Windows `Handle`sChris Denton-0/+16
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