Fix regression from #140393 for espidf / horizon / nuttx / vita
#140393 introduced changes to the layout of the `std::sys::process` code.
As a result, the Tier 3 ESP-IDF (and I suspect Horizon, Nuttx and Vita targets as well) no longer build.
A `pub use unsupported::output` is all that was missing - for the above OSes specifically. This explicit `pub use` is now necessary, because #140393 moved the `output` function to module-level, where it was previously part of `Command` and was thus re-exported automatically, as part of the `imp::Command` re-export further down the file containing the one-liner fix.
Note that - with the change introduced by #140393 - we **can't** anymore just do an unconditional `pub use imp::output` as this function simply does not exist anymore anywhere else but in the `unsupported` module.
r? `@joboet`
[rustdoc] Ensure that temporary doctest folder is correctly removed even if doctests failed
Fixes#139899.
The bug was due to the fact that if any doctest fails for any reason, we call `exit` (or it's called inside `libtest` if not edition 2024), meaning that `TempDir`'s destructor isn't called, and therefore the temporary folder isn't cleaned up.
Took me a while to figure out how to reproduce but finally I was able to reproduce the bug with:
`````rust
#![doc(test(attr(deny(warnings))))]
//! ```
//! let a = 12;
//! ```
`````
And then I ensured that panicking doctests were cleaned up as well:
`````rust
//! ```
//! panic!();
//! ```
`````
And finally I checked if it was fixed for merged doctests too (`--edition 2024`).
To make this work, I needed to add a new public function in `libtest` too which would call a function once all tests have been run.
So only issue is: I have absolutely no idea how we can add a regression test for this fix. If anyone has an idea...
r? `@notriddle`
collect all Fuchsia bindings into the `fuchsia` module
The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally:
* deduplicates the definitions
* makes the error names consistent
* marks `zx_thread_self` and `zx_clock_get_monotonic` as safe extern functions
* removes unused items (there's no need to maintain these bindings if we're not going to use them)
* removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden)
`@rustbot` ping fuchsia
Comment on `Rc` abort-guard strategy without naming unrelated fn
`wrapped_add` is used, not `checked_add`, so avoid mentioning specific fn calls that may vary slightly based on "whatever produces the best code" and focus on things that will remain constant into the future.
Stabilize proc_macro::Span::{file, local_file}.
Stabilizes this part of https://github.com/rust-lang/rust/issues/54725:
```rust
impl Span {
pub fn file(&self) -> String; // Mapped/artificial file name, for display purposes.
pub fn local_file(&self) -> Option<PathBuf>; // Real file name as it exists on the local file system.
}
```
See also the naming discussion in https://github.com/rust-lang/rust/issues/139903
std: get rid of `sys_common::process`
Move the public `CommandEnvs` into the `process` module (and make it a wrapper type for an internal iterator type) and everything else into `sys::process` as per #117276.
Something went wrong with a force push, so I can't reopen#139020. This is unchanged from that PR, apart from a rebase.
r? ```@thomcc```
Consistent trait bounds for ExtractIf Debug impls
Closes#137654. Refer to that issue for a table of the **4** different impl signatures we previously had in the standard library for Debug impls of various ExtractIf iterator types.
The one we are standardizing on is the one so far only used by `alloc::collections::linked_list::ExtractIf`, which is _no_ `F: Debug` bound, _no_ `F: FnMut` bound, only `T: Debug` bound.
This PR applies the following signature changes:
```diff
/* alloc::collections::btree_map */
pub struct ExtractIf<'a, K, V, F, A = Global>
where
- F: 'a + FnMut(&K, &mut V) -> bool,
Allocator + Clone,
impl Debug for ExtractIf<'a, K, V, F,
+ A,
>
where
K: Debug,
V: Debug,
- F: FnMut(&K, &mut V) -> bool,
+ A: Allocator + Clone,
```
```diff
/* alloc::collections::btree_set */
pub struct ExtractIf<'a, T, F, A = Global>
where
- T: 'a,
- F: 'a + FnMut(&T) -> bool,
Allocator + Clone,
impl Debug for ExtractIf<'a, T, F, A>
where
T: Debug,
- F: FnMut(&T) -> bool,
A: Allocator + Clone,
```
```diff
/* alloc::collections::linked_list */
impl Debug for ExtractIf<'a, T, F,
+ A,
>
where
T: Debug,
+ A: Allocator,
```
```diff
/* alloc::vec */
impl Debug for ExtractIf<'a, T, F, A>
where
T: Debug,
- F: Debug,
A: Allocator,
- A: Debug,
```
```diff
/* std::collections::hash_map */
pub struct ExtractIf<'a, K, V, F>
where
- F: FnMut(&K, &mut V) -> bool,
impl Debug for ExtractIf<'a, K, V, F>
where
+ K: Debug,
+ V: Debug,
- F: FnMut(&K, &mut V) -> bool,
```
```diff
/* std::collections::hash_set */
pub struct ExtractIf<'a, T, F>
where
- F: FnMut(&T) -> bool,
impl Debug for ExtractIf<'a, T, F>
where
+ T: Debug,
- F: FnMut(&T) -> bool,
```
I have made the following changes to bring these types into better alignment with one another.
- Delete `F: Debug` bounds. These are especially problematic because Rust closures do not come with a Debug impl, rendering the impl useless.
- Delete `A: Debug` bounds. Allocator parameters are unstable for now, but in the future this would become an API commitment that we do not debug-print a representation of the allocator when printing an iterator.
- Delete `F: FnMut` bounds. Requires `hashbrown` PR: https://github.com/rust-lang/hashbrown/pull/616. **API commitment:** we commit to not doing RefCell voodoo inside ExtractIf to have some way for its Debug impl (which takes &self) to call a FnMut closure, if this is even possible.
- Add `T: Debug` bounds (or `K`/`V`), even on Debug impls that do not currently make use of them, but might in the future. **Breaking change.** Must backport into Rust 1.87 (current beta) or do a de-stabilization PR in beta to delay those types by one release.
- Render using `debug_struct` + `finish_non_exhaustive`, instead of `debug_tuple`.
- Do not render the _entire_ underlying collection.
- Show a "peek" field indicating the current position of the iterator.
The Fuchsia bindings are currently spread out across multiple modules in `sys/pal/unix` leading to unnecessary duplication. This PR moves all of these definitions into `sys::pal::unix::fuchsia` and additionally:
* deduplicates the definitions
* makes the error names consistent
* marks some extern functions as safe
* removes unused items (there's no need to maintain these bindings if we're not going to use them)
* removes the documentation for the definitions (contributors should always consult the platform documentation, duplicating that here is just an extra maintenance burden)
Correct `extract_if` sample equivalent.
Tracking issue: https://github.com/rust-lang/rust/issues/43244
Original PR: #133265
The sample code marked as equivalent in the doc comment isn't currently equivalent. Given the same predicate and range, if your vector were `[1, 2, 3, 3, 3, 3, 3, 3, 4, 5, 6]`, then all of the 3s would be removed. `i` is only incremented when an element is dropped, but `range.end` is unchanged, so the items shift down. I got very confused when reading the docs and trying to square this sample code with the explanation of how the function works.
Fortunately, the real `extract_if()` does not have this problem. I've added an `end` variable to align the behavior. I've also taken the opportunity to simplify the predicate, which now just matches odd numbers, and to pad out the vec of numbers to line up the zero-indexed range with the integers in the vec.
r? the8472
Suggest `retain_mut` over `retain` as `Vec::extract_if` alternative
The docs for `Vec::extract_if` suggest using `Vec::retain` if the user doesn't need the removed item. Given that `extract_if` gives a mutable reference to the evaluated element, `retain_mut` is the most appropriate alternative, not `retain`.
stabilize ptr::swap_nonoverlapping in const
Closes https://github.com/rust-lang/rust/issues/133668
The blocking issue mentioned there is resolved by documentation. We may in the future actually support such code, but that is blocked on https://github.com/rust-lang/const-eval/issues/72 which is non-trivial to implement. Meanwhile, this completes stabilization of all `const fn` in `ptr`. :)
Here's a version of the problematic example to play around with:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=6c390452379fb593e109b8f8ee854d2a
Should be FCP'd with both `@rust-lang/libs-api` and `@rust-lang/lang` since `swap_nonoverlapping` is documented to work as an "untyped" operation but due to the limitation mentioned above, that's not entirely true during const evaluation. I expect this limitation will only be hit in niche corner cases, so the benefits of having this function work most of the time outweigh the downsides of users running into this problem. (Note that unsafe code could already hit this limitation before this PR by doing cursed pointer casts, but having it hidden inside `swap_nonoverlapping` feels a bit different.)
doc(std): fix typo lchown -> lchmod
chown is irrelevant here, as this function does not affect file ownership. chmod is the correct function to reference here.
Use present indicative tense in std::io::pipe() API docs
The inline documentation for all other free functions in the `std::io` module use the phrase "creates a" instead of "create a", except for the currently nightly-only `std::io::pipe()` function. This commit updates the text to align with the predominant wording in the `std::io` module.
I recognize this PR is quite a minuscule nitpick, so feel free to ignore and close if you disagree and/or there are bigger fish to fry. Thanks in advance! 😄
Relates to https://github.com/rust-lang/rust/issues/127154.
Remove `avx512dq` and `avx512vl` implication for `avx512fp16`
According to Intel, `avx512fp16` requires only `avx512bw`, but LLVM also enables `avx512vl` and `avx512dq` when `avx512fp16` is active. This is relic code, and will be fixed in LLVM soon. We should remove this from Rust too asap, especially before the stabilization of AVX512
Related:
- llvm/llvm-project#136209
- #138940
- rust-lang/stdarch#1781
- #111137
``@rustbot`` label O-x86_64 O-x86_32 A-SIMD A-target-feature T-compiler -T-libs
r? ``@Amanieu``
**Update: the LLVM fix has been merged**
cc ``@rust-lang/wg-llvm`` will it be possible to update the rustc llvm version to something after llvm/llvm-project#137450
Avoid redundant WTF-8 checks in `PathBuf`
Eliminate checks for WTF-8 boundaries in `PathBuf::set_extension` and `add_extension`, where joining WTF-8 surrogate halves is impossible. Don't convert the `str` to `OsStr`, because `OsString::push` specializes to skip the joining when given strings.
To assist in this, mark the internal methods `OsString::truncate` and `extend_from_slice` as `unsafe` to communicate their safety invariants better than with module privacy.
Similar to #137777.
cc `@joboet` `@ChrisDenton`
Delegate to inner `vec::IntoIter` from `env::ArgsOs`
Delegate from `std::env::ArgsOs` to the methods of the inner platform-specific iterators, when it would be more efficient than just using the default methods of its own impl. Most platforms use `vec::IntoIter` as the inner type, so prioritize delegating to the methods it provides.
`std::env::Args` is implemented atop `std::env::ArgsOs` and performs UTF-8 validation with a panic for invalid data. This is a visible effect which users certainly rely on, so we can't skip any arguments. Any further iterator methods would skip some elements, so no change is needed for that type.
Add `#[inline]` for any methods which simply wrap the inner iterator.
Clarify `async` block behaviour
Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) #101444.
r? rust-lang/docs
std: use the address of `errno` to identify threads in `unique_thread_exit`
Getting the address of `errno` should be just as cheap as `pthread_self()` and avoids having to use the expensive `Mutex` logic because it always results in a pointer.