Commit graph

26486 commits

Author SHA1 Message Date
Jonathan Brouwer
305209f8cd
Rollup merge of #150048 - pthariensflame:patch-1, r=Amanieu
std_detect: AArch64 Darwin: expose SME F16F16 and B16B16 features

This synchronizes the list with the current state of `sysctl` on macOS “Tahoe” 26.2.

r? ``@Amanieu``
2025-12-18 18:37:18 +01:00
Jonathan Brouwer
663d8432f1
Rollup merge of #145933 - GrigorenkoPV:thing_as_thing, r=Amanieu
Expand `str_as_str` to more types

Tracking issue: rust-lang/rust#130366
ACP: https://github.com/rust-lang/libs-team/issues/643

This PR expands `str_from_str` feature and adds analogous methods to more types. Namely:
- `&CStr`
- `&[T]`, `&mut [T]`
- `&OsStr`
- `&Path`
- `&ByteStr`, `&mut ByteStr` (tracking issue:  rust-lang/rust#134915) (technically was not part of ACP)
2025-12-18 18:37:13 +01:00
Jonathan Brouwer
4ea24671ed
Rollup merge of #150113 - Darksonn:pin-coerce-unsized-to-150112, r=jackh726
Update tracking issue for PinCoerceUnsized

This uses the newly created tracking issue https://github.com/rust-lang/rust/issues/150112.

Please see https://github.com/rust-lang/rust/issues/68015#issuecomment-3665424732 for motivation.

r? ``@jackh726``
2025-12-17 23:31:22 +01:00
Alice Ryhl
78f52c1d12 Update tracking issue for PinCoerceUnsized 2025-12-17 20:26:41 +00:00
Matthias Krüger
92bd07b17d
Rollup merge of #150096 - Amanieu:revert-borrowedbuf, r=ChrisDenton
Revert #148937

https://github.com/rust-lang/rust/issues/148937:  Remove initialized-bytes tracking from `BorrowedBuf` and `BorrowedCursor`

This caused several performance regressions because of existing code which uses `Read::read` and therefore requires full buffer initialization. This is particularly a problem when the same buffer is re-used for multiple read calls since this means it needs to be fully re-initialized each time.

There is still some benefit to landing the API changes, but we will have to add private APIs so that the existing infrastructure can track and avoid redundant initialization.
2025-12-17 18:46:19 +01:00
Matthias Krüger
15c54bc004
Rollup merge of #150088 - folkertdev:riscv-pause-miri, r=RalfJung
miri: add `miri_spin_loop` to make `hint::spin_loop` work consistently

fixes https://github.com/rust-lang/rust/issues/150050

Always use the same implementation when running miri (regardless of target, for consistency). This implementation yields the current thread to try find actual bugs.

r? RalfJung
2025-12-17 18:46:18 +01:00
Folkert de Vries
c7dd19b8d6
add miri_spin_loop to make hint::spin_loop work consistently 2025-12-17 16:00:39 +01:00
Amanieu d'Antras
4b07875505 Revert #148937 (Remove initialized-bytes tracking from BorrowedBuf and BorrowedCursor)
This caused several performance regressions because of existing code
which uses `Read::read` and therefore requires full buffer
initialization. This is particularly a problem when the same buffer is
re-used for multiple read calls since this means it needs to be fully
re-initialized each time.

There is still some benefit to landing the API changes, but we will have
to add private APIs so that the existing infrastructure can
track and avoid redundant initialization.
2025-12-17 14:34:56 +00:00
Juho Kahala
a9fa80ce91
Fix expm1f overflow threshold
Due to an erroneous overflow threshold, `expm1f` was incorrectly
returning `inf` for inputs in the range `[88.72169, 88.72283]`. This
additionally caused `sinhf` to return `NaN` for inputs in that range.

The bug was ported from the original in musl, which has since been fixed
in [1].

[1]: https://git.musl-libc.org/cgit/musl/commit/?id=964104f9f0e056cf58d9defa0b716d7756f040f6
2025-12-17 05:56:45 +00:00
Juho Kahala
5faeb43a5c
remove uses of Ord::clamp in scalbn (#1047)
Avoid using `Ord::clamp` in the `f16`-specific part of the generic
`scalbn`.

It turned out to be redundant anyway, as both callsites follow a pattern
like
```
if n < negative_val {
    let foo = (n + positive_val).clamp(negative_val, positive_val);
}
```
and `n < negative_val < 0` implies `n + positive_val < positive_val`.

Fixes: rust-lang/compiler-builtins#1046
2025-12-17 05:56:27 +00:00
quaternic
bd06672d1a apply the rename to aarch64_outline_atomics in builtins-test 2025-12-17 05:01:44 +00:00
The rustc-josh-sync Cronjob Bot
18067a7fc8 Merge ref '2dc30247c5' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: 2dc30247c5
Filtered ref: dab12aee0f52f7b83cc62ae565855c731bed502f
Upstream diff: 47cd7120d9...2dc30247c5

This merge was created using https://github.com/rust-lang/josh-sync.
2025-12-17 04:58:31 +00:00
The rustc-josh-sync Cronjob Bot
fe791619d0 Prepare for merging from rust-lang/rust
This updates the rust-version file to 2dc30247c5.
2025-12-17 04:56:18 +00:00
Jonathan Brouwer
ff84058781
Rollup merge of #150064 - Ayush1325:uefi-io-repr-comment, r=bjorn3
std: io: error: Add comment for UEFI unpacked repr use

The following commit adds the comment explaining the rational why UEFI uses unpacked representation on 64-bit platforms as opposed to bit-packed representation used in all other 64-bit platforms.

r? `@bjorn3`
2025-12-16 20:21:13 +01:00
Jonathan Brouwer
25b73c4943
Rollup merge of #150033 - izagawd:try_as_dyn, r=oli-obk
Add try_as_dyn and try_as_dyn_mut

Tracking issue: https://github.com/rust-lang/rust/issues/144361

Continuation of: https://github.com/rust-lang/rust/pull/144363
2025-12-16 20:21:10 +01:00
Jonathan Brouwer
ef2c71c3cc
Rollup merge of #149967 - folkertdev:va-list-hexagon, r=workingjubilee
custom `VaList` layout for Hexagon

I noticed while browsing LLVM source that we use an incorrect `VaList` definition for the musl hexagon target.

relevant links

- 0cdc1b6dd4/clang/include/clang/Basic/TargetInfo.h (L333)
- 0cdc1b6dd4/clang/lib/CodeGen/Targets/Hexagon.cpp (L407-L417)

cc target maintainer `@androm3da` can you confirm that this looks OK? In particular the `#[rustc_pass_indirectly_in_non_rustic_abis]` attribute is used to simulate pointer decay (like if the struct were wrapped in a 1-element array in C). The clang comment suggests that the Tag is wrapped in such a single-element array, but I haven't actually been able to confirm it.

For stabilizing `c_variadic` (on the hexagon targets) we will also need a custom `va_arg` implementation to mirror the one in `clang` in [va_arg.rs](https://github.com/rust-lang/rust/blob/main/compiler/rustc_codegen_llvm/src/va_arg.rs). Would you be able to contribute one?

r? `@workingjubilee`
2025-12-16 20:21:08 +01:00
Jonathan Brouwer
297cdc8137
Rollup merge of #149804 - xiaolinny:main, r=lcnr
chore: fix some minor issues in the comments

fix some minor issues in the comments
2025-12-16 20:21:08 +01:00
Jonathan Brouwer
d93b93bcb0
Rollup merge of #147939 - theemathas:add-const-supertrait, r=oli-obk
Make `const BorrowMut` require `const Borrow` and make `const Fn` require `const FnMut`

This makes it consistent with other const traits in the standard library with supertraits.

I am currently unsure if `const FnMut` should require `const FnOnce` or not. See [zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/146212-t-compiler.2Fconst-eval/topic/.5Bconst.5D.20implied.20bounds.20for.20implicit.20trait.20bounds/near/546152748).
2025-12-16 20:21:05 +01:00
Ayush Singh
4efe2681f7
std: io: error: Add comment for UEFI unpacked repr use
The following commit adds the comment explaining the rational why UEFI
uses unpacked representation on 64-bit platforms as opposed to bit-packed
representation used in all other 64-bit platforms.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-12-16 22:27:42 +05:30
Ivar Flakstad
d5bf1a4c9a Introduce vtable_for intrinsic and use it to implement try_as_dyn and try_as_dyn_mut for fallible coercion from &T / &mut T to &dyn Trait. 2025-12-16 06:39:58 -04:00
Laine Taffin Altman
8d37589f37
std_detect: AArch64 Darwin: expose SME F16F16 and B16B16 features
This synchronizes the list with the current state of `sysctl` on macOS “Tahoe” 26.2.


r? @Amanieu
2025-12-15 22:08:00 -08:00
Stuart Cook
2739ccb2b1
Rollup merge of #150021 - david-d-h:main, r=ChrisDenton
document that mpmc channels deliver an item to (at most) one receiver

Tiny documentation change related to mpmc (tracking issue rust-lang/rust#126840).

This PR is meant to supersede rust-lang/rust#140158 due to it's inactivity. It is essentially the same addition structured a little differently.
2025-12-16 14:40:45 +11:00
Stuart Cook
2de952e813
Rollup merge of #149459 - Ayush1325:uefi-fs-setinfo, r=joboet
std: sys: fs: uefi: Implement set_times and set_perm

- Tested on QEMU OVMF.
2025-12-16 14:40:42 +11:00
Folkert de Vries
023f38fe73
custom VaList layout for Hexagon 2025-12-15 20:00:05 +01:00
bors
21ff67df15 Auto merge of #149930 - joboet:small-sys-refactor, r=ChrisDenton
std: small `sys` refactor

Part of rust-lang/rust#117276

The large number of files changed just results from the need to update a lot of imports. Actually this PR only:
* combines the two definitions of `RawOsError` in `sys::pal` into one in `sys::io`
* moves `FULL_BACKTRACE_DEFAULT` from `sys::pal` to `sys::backtrace`
* moves the `FromInner`/`IntoInner`/... traits into `sys` (in preparation for removing `sys_common` entirely)
2025-12-15 18:46:48 +00:00
Ayush Singh
9c14e3f631
std: sys: fs: uefi: Implement set_times and set_perm
- Tested on QEMU OVMF.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-12-15 18:48:10 +05:30
David
7cf35566e3 document that mpmc channels deliver an item to (at most) one receiver 2025-12-15 14:09:13 +01:00
joboet
33409da171
std: update references to FromInner etc. 2025-12-15 14:00:37 +01:00
joboet
19acd4f491
std: move FromInner etc. to sys
... and remove the `#[doc(hidden)]` in favour of making them `pub(crate)`.
2025-12-15 13:48:30 +01:00
joboet
854df94584
std: move FULL_BACKTRACE_DEFAULT to sys::backtrace 2025-12-15 13:48:30 +01:00
joboet
aa73de400d
std: move RawOsError to sys::io 2025-12-15 13:48:30 +01:00
Matthias Krüger
dc6fade06f
Rollup merge of #149997 - cvengler:posix-gettime, r=joboet
Link POSIX instead of Linux manual for Instant

This commit changes the links in the source code that link to a platform specific implementation of the POSIX interface of `clock_gettime`, despite the respective areas in the code being specifically UNIX system agnostic, thereby making it more reasonable to link the POSIX specific document.
2025-12-15 08:08:04 +01:00
Matthias Krüger
18fa9ddd77
Rollup merge of #149744 - lemire:main, r=Mark-Simulacrum
test: update duplicate many_digits test to use f64 instead of f32

Replace the f32 test case with an f64 equivalent to improve coverage for parsing large digit counts in double-precision floating-point conversion. Specifically, this PR updates the `many_digits` test in `library/coretests/tests/num/dec2flt/parse.rs` to test f64 (double-precision) parsing instead of f32 (single-precision).

The test verifies that decimal strings with an excessive number of digits (beyond `Decimal::MAX_DIGITS`) are parsed correctly, ensuring proper truncation of insignificant digits. Previously, the same test was repeated twice (see comment https://github.com/rust-lang/rust/pull/86761#issuecomment-3623334228 by `@Viatorus).`

## Changes

- Replaced the duplicated f32 test case with an equivalent f64 test case.
- Updated the expected bit pattern and input string to a very long decimal with many trailing zeros, testing the limits of f64 precision.
2025-12-15 08:08:01 +01:00
Matthias Krüger
d05ddf5647
Rollup merge of #149885 - inkreasing:push-ovrwrllvzvmw, r=joboet
replace addr_of_mut with &raw mut in maybeuninit docs

In the docs for `addr_of_mut` it says that the macro is "soft-deprecated" so maybe the std docs should stop recommending it.
I searched for other places where this is used, but didn't find any in public stable documentation.
2025-12-14 20:04:56 +01:00
Matthias Krüger
ce2eec1b0c
Rollup merge of #149864 - alexcrichton:wasi-avoid-linkat, r=joboet
std: Don't use `linkat` on the `wasm32-wasi*` targets

This commit is a follow-up to rust-lang/rust#147572 and the issue reported at the end of that PR where the `std::fs::hard_link` function is broken after that PR landed. The true culprit and bug here is fixed in WebAssembly/wasi-libc#690 but until that's released in a wasi-sdk version it should be reasonable, on WASI, to skip the `linkat` function.
2025-12-14 20:04:55 +01:00
Matthias Krüger
a8460d0cf2
Rollup merge of #149837 - scottmcm:wrapping-shift-docs, r=workingjubilee
Update `wrapping_sh[lr]` docs and examples

Inspired by [#general > &#96;Source&#96; link for &#96;core&#96; items is often inscrutable @ 💬][zulip-thread] I wanted to add some more examples of the actual wrapping as well as update the documentation to emphasize that the behaviour is unusual.

In particular, now that `unbounded_sh[lr]` is stable, point people trying to avoid panics to that instead, since it behaves less weirdly.

[zulip-thread]: https://rust-lang.zulipchat.com/#narrow/channel/122651-general/topic/.60Source.60.20link.20for.20.60core.60.20items.20is.20often.20inscrutable/near/562774474
2025-12-14 20:04:55 +01:00
Matthias Krüger
e4ca889ed8
Rollup merge of #146794 - joboet:reorganize-pipe, r=Mark-Simulacrum
std: reorganize pipe implementations

Currently, there are two distinct types called `AnonPipe` in `std`:
* The one used to implement `io::pipe` (in `sys::anonymous_pipe`)
* The one used to implement `Stdin`/`Stdout`/`Stderr` (in `sys::pal::pipe`)

On Windows, these actually have different semantics, as one of the handles returned by the `sys::pal::pipe` version is opened for asynchronous operation in order to support `read2`, whereas the `sys::anonymous_pipe` version does not do so. Thus the naming is extremely confusing.

To fix this, this PR renames the `sys::anonymous_pipe` version of `AnonPipe` to simply `Pipe`, whereas the `sys::pal::pipe` version is now called `ChildPipe`. Additionally,
* `sys::anonymous_pipe` is now also just called `sys::pipe`.
* On Windows, `sys::pal::pipe` has been moved to `sys::process` and is now called `sys::process::child_pipe`.
* On non-Windows platforms, pipe creation is now exclusively handled by `sys::pipe` and `ChildPipe` is defined as a type alias to `Pipe` within `sys::process`.

And lastly, the `read2` function (originally in `sys::pal::pipe`) is now called `read_output` and defined by `sys::process`, as (at least on Windows) it is only usable with `ChildPipe`.

Includes rust-lang/rust#146639 for convenience.
2025-12-14 20:04:53 +01:00
Clara Engler
1e4befda53
Link POSIX instead of Linux manual for Instant
This commit changes the links in the source code that link to a platform
specific implementation of the POSIX interface of `clock_gettime`,
despite the respective areas in the code being specifically UNIX system
agnostic, thereby making it more reasonable to link the POSIX specific
document.
2025-12-14 19:36:41 +01:00
Chris Denton
735c45eda4
Rollup merge of #149272 - DrAsu33:fix-vec-iter-zst-alignment-148682, r=Mark-Simulacrum
Fix vec iter zst alignment

Closes rust-lang/rust#148682
2025-12-14 09:18:28 +00:00
Chris Denton
46814a9e9c
Rollup merge of #148825 - cvengler:time_systemtime_limits, r=ChrisDenton
Add SystemTime::{MIN, MAX}

Accepted ACP: <https://github.com/rust-lang/libs-team/issues/692>
Tracking Issue: <https://github.com/rust-lang/rust/issues/149067>

---

This merge request introduces two new constants to `SystemTime`: `MIN` and `MAX`, whose values represent the maximum values for the respective data type, depending upon the platform.

Technically, this value is already obtainable during runtime with the following algorithm:
Use `SystemTime::UNIX_EPOCH` and call `checked_add` (or `checked_sub`) repeatedly with `Duration::new(0, 1)` on it, until it returns None.
Mathematically speaking, this algorithm will terminate after a finite amount of steps, yet it is impractical to run it, as it takes practically forever.

Besides, this commit also adds a unit test to verify those values represent the respective minimum and maximum, by letting a `checked_add` and `checked_sub` on it fail.

In the future, the hope of the authors lies within the creation of a `SystemTime::saturating_add` and `SystemTime::saturating_sub`, similar to the functions already present in `std::time::Duration`.
However, for those, these constants are crucially required, thereby this should be seen as the initial step towards this direction.
With this change, implementing these functions oneself outside the standard library becomes feasible in a portable manner for the first time.

This feature (and a related saturating version of `checked_{add, sub}` has been requested multiple times over the course of the past few years, most notably:
* rust-lang/rust#100141
* rust-lang/rust#133525
* rust-lang/rust#105762
* rust-lang/rust#71224
* rust-lang/rust#45448
* rust-lang/rust#52555
2025-12-14 09:18:27 +00:00
Chris Denton
01e40d6755
Rollup merge of #148755 - nxsaken:const_drop_guard, r=dtolnay
Constify `DropGuard::dismiss` and trait impls

Feature: `drop_guard` (rust-lang/rust#144426), `const_convert` (rust-lang/rust#143773), `const_drop_guard` (no tracking issue yet)

Constifies `DropGuard::dismiss` and trait impls.
I reused `const_convert` (rust-lang/rust#143773) for the `Deref*` impls.
2025-12-14 09:18:26 +00:00
bors
3f4dc1e02d Auto merge of #146348 - jdonszelmann:eiiv3, r=lcnr,oli-obk
Externally implementable items

Supersedes https://github.com/rust-lang/rust/pull/140010
Tracking issue: https://github.com/rust-lang/rust/issues/125418

Getting started:

```rust
#![feature(eii)]

#[eii(eii1)]
pub fn decl1(x: u64)
// body optional (it's the default)
{
    println!("default {x}");
}

// in another crate, maybe
#[eii1]
pub fn decl2(x: u64) {
    println!("explicit {x}");
}

fn main() {
    decl1(4);
}
```

- tiny perf regression, underlying issue makes multiple things in the compiler slow, not just EII, planning to solve those separately.
- No codegen_gcc support, they don't have bindings for weak symbols yet but could
- No windows support yet for weak definitions

This PR merges the implementation of EII for just llvm + not windows, doesn't yet contain like a new panic handler implementation or alloc handler. With this implementation, it would support implementing the panic handler in terms of EII already since it requires no default implementation so no weak symbols

The PR has been open in various forms for about a year now, but I feel that having some implementation merged to build upon
2025-12-14 04:20:26 +00:00
increasing
ebbb4d5ea4 replace addr_of_mut with &raw mut in maybeuninit docs 2025-12-13 13:27:10 +01:00
Clara Engler
d80348b6c9
time: Fix Windows' SystemTime::checked_sub
The Windows implementation of `SystemTime::checked_sub` contains a bug,
namely that it does not return `None` on values below 1601.

This bug stems from the fact that internally, the time gets converted to
an i64, with zero representing the anchor in 1601.  Of course,
performing checked subtraction on a signed integer generally works fine.
However, the resulting value delivers undefined behavior on Windows
systems.

To mitigate this issue, we try to convert the resulting i64 to an u64
because a negative value should obviously fail there.
2025-12-13 12:34:51 +01:00
nxsaken
0ecf91a701 Use an explicit receiver in DropGuard::dismiss 2025-12-13 14:00:44 +04:00
Clara Engler
1b9b4f4dc6 time: Test and document time precision edge-case
There is a slight edge case when adding and subtracting a `Duration`
from a `SystemTime`, namely when the duration itself is finer/smaller
than the time precision on the operating systems.

On most (if not all non-Windows) operating systems, the precision of
`Duration` aligns with the `SystemTime`, both being one nanosecond.

However, on Windows, this time precision is 100ns, meaning that adding
or subtracting a `Duration` whose value is `< Duration::new(0, 100)`
will result in that method behaving like an addition/subtracting of
`Duration::ZERO`, due to the `Duration` getting rounded-down to the zero
value.
2025-12-13 10:44:48 +01:00
joboet
653520afb2
std: update pipe tests 2025-12-12 21:25:02 +01:00
joboet
860716faa3
std: reorganize pipe implementations 2025-12-12 21:25:00 +01:00
Clara Engler
ac5c70ad4d
time: Implement SystemTime::{MIN, MAX}
This commit introduces two new constants to SystemTime: `MIN` and `MAX`,
whose value represent the maximum values for the respective data type,
depending upon the platform.

Technically, this value is already obtainable during runtime with the
following algorithm: Use `SystemTime::UNIX_EPOCH` and call `checked_add`
(or `checked_sub`) repeatedly with `Duration::new(0, 1)` on it, until it
returns None.  Mathematically speaking, this algorithm will terminate
after a finite amount of steps, yet it is impractical to run it, as it
takes practically forever.

Besides, this commit also adds a unit test.  Concrete implementation
depending upon the platform is done in later commits.

In the future, the hope of the authors lies within the creation of a
`SystemTime::saturating_add` and `SystemTime::saturating_sub`, similar
to the functions already present in `std::time::Duration`.  However, for
those, these constants are crucially required, thereby this should be
seen as the initial step towards this direction.

Below are platform specifc notes:

# Hermit

The HermitOS implementation is more or less identitcal to the Unix one.

# sgx

The implementation uses a `Duration` to store the Unix time, thereby
implying `Duration::ZERO` and `Duration::MAX` as the limits.

# solid

The implementation uses a `time_t` to store the system time within a
single value (i.e. no dual secs/nanosecs handling), thereby implying its
`::MIN` and `::MAX` values as the respective boundaries.

# UEFI

UEFI has a weird way to store times, i.e. a very complicated struct.
The standard proclaims "1900-01-01T00:00:00+0000" to be the lowest
possible value and `MAX_UEFI_TIME` is already present for the upper
limit.

# Windows

Windows is weird.  The Win32 documentation makes no statement on a
maximum value here.  Next to this, there are two conflicting types:
`SYSTEMTIME` and `FILETIME`.  Rust's Standard Library uses `FILETIME`,
whose limit will (probably) be `i64::MAX` packed into two integers.
However, `SYSTEMTIME` has a lower-limit.

# xous

It is similar to sgx in the sense of using a `Duration`.

# unsupported

Unsupported platforms store a `SystemTime` in a `Duration`, just like
sgx, thereby implying `Duration::ZERO` and `Duration::MAX` as the
respective limits.
2025-12-12 12:25:30 +01:00
Matthias Krüger
b826d06771
Rollup merge of #149791 - clubby789:cfg-bool-lints, r=jdonszelmann
Remove uses of `cfg({any()/all()})`

~~This implements the followup warning suggested in https://github.com/rust-lang/rfcs/pull/3695~~
~~Lint against an empty `cfg(any/all)`, suggest the boolean literal equivalents.~~
https://github.com/rust-lang/rust/pull/149791#issuecomment-3638624348

Tracking issue: https://github.com/rust-lang/rust/issues/131204
2025-12-12 12:19:09 +01:00