161 Commits

Author SHA1 Message Date
Josh Stone
a81ed52f58 Add a regression test for rust-lang/rust#147971 2025-10-23 12:37:53 -07:00
bors
c7a635f33c Auto merge of #147910 - joboet:wait_timeout-spurious-test, r=ChrisDenton
handle spurious returns of `wait_timeout` in test

Fixes https://github.com/rust-lang/rust/issues/147885
Closes https://github.com/rust-lang/rust/pull/147871

`wait_timeout` is allowed to spuriously return, hence the `timeout_nanoseconds` must not assume that the wakeup resulted from a `notify_all()`.
2025-10-20 22:04:39 +00:00
joboet
76dfdd4e70 handle spurious returns of wait_timeout in test 2025-10-20 17:53:49 +02:00
Matthias Krüger
8d6356b8d8 Rollup merge of #143191 - connortsui20:stabilize-rwlock-downgrade, r=tgross35
Stabilize `rwlock_downgrade` library feature

Tracking Issue: https://github.com/rust-lang/rust/issues/128203

Method to be stabilized:

```rust
impl<'a, T: ?Sized> RwLockWriteGuard<'a, T> {
    pub fn downgrade(s: Self) -> RwLockReadGuard<'a, T> {}
}
```

~~I would like to point out that my documentation comment is longer than ideal, but at the same time I don't really know how else to show why `downgrade` is actually necessary (instead of just unlocking and relocking). If anyone has ideas for making this more concise that would be great!~~ I have made the documentation a bit more clear.

Stabilization report: https://github.com/rust-lang/rust/issues/128203#issuecomment-3016682463
2025-10-15 23:41:00 +02:00
joboet
8a145efc70 std: improve handling of timed condition variable waits on macOS 2025-10-14 11:57:50 +02:00
EFanZh
ba42380142 Implement non-poisoning Mutex::with_mut, RwLock::with and RwLock::with_mut
ACP: https://github.com/rust-lang/libs-team/issues/497.
2025-10-04 17:16:00 +08:00
Matthias Krüger
92aac1bdf6 Rollup merge of #146281 - Jules-Bertholet:static-align-thread-local, r=Mark-Simulacrum
Support `#[rustc_align_static]` inside `thread_local!`

Tracking issue: rust-lang/rust#146177

```rust
thread_local! {
    #[rustc_align_static(64)]
    static SO_ALIGNED: u64 = const { 0 };
}
```

This increases the amount of recursion the macro performs (once per attribute in addition to the previous once per item), making it easier to hit the recursion limit. I’ve added workarounds to limit the impact in the case of long doc comments, but this still needs a crater run just in case.

r? libs

``@rustbot`` label A-attributes A-macros A-thread-locals F-static_align T-libs
2025-10-02 10:27:48 +02:00
Matthias Krüger
61b9467af8 Rollup merge of #142506 - clarfonthey:path-trailing-sep, r=joboet
Add `Path::has_trailing_sep` and related methods

Implements rust-lang/libs-team#335.

Tracking issue: rust-lang/rust#142503

Notable differences from ACP:

* `trim_trailing_sep` was added to `Path` since it felt reasonable to ensure that the inverse operation was available.
* Per suggestion of `@kennytm,` added `push_trailing_sep` and `pop_trailing_sep` to `PathBuf` in addition to `set_trailing_sep`.

This also updates some of the docs on various `Path` methods to use the term "trailing separator" instead of "trailing slash" for consistency.
2025-09-30 20:46:44 +02:00
Jules Bertholet
a4e87e9406 Support #[rustc_align_static] inside thread_local! 2025-09-26 13:51:09 -04:00
Matthias Krüger
d10d6bfb02 Rollup merge of #146958 - el-ev:fix_path_string_eq_recurse, r=joboet
Fix infinite recursion in Path::eq with String

- Closes [after beta backport] rust-lang/rust#146940
2025-09-24 23:33:28 +02:00
Stepan Koltsov
92859e98ee Repro duration_since regression from issue 146228 2025-09-24 21:07:26 +01:00
Iris Shi
5a4e536036 Fix infinite recursion in Path::eq with String 2025-09-24 21:30:41 +08:00
Mads Marquart
37be93497e Fix test suite in iOS/tvOS/watchOS/visionOS simulator 2025-09-19 13:55:03 +02:00
Connor Tsui
6354c51d2b update doc comment
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-09-11 13:08:44 -04:00
Connor Tsui
18d0dcbc8e fix config for poison macro test
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-09-11 12:35:26 -04:00
Matthias Krüger
d061896a37 Rollup merge of #146322 - weiznich:fix/146087, r=joboet
Make Barrier RefUnwindSafe again

This commit manually implements `RefUnwindSafe` for `std::sync::Barrier` to fix rust-lang/rust#146087. This is a fix for a regression indroduced by e95db591a4
2025-09-10 20:29:07 +02:00
Georg Semmler
30fd32eca5 Make the compile test use a const instead 2025-09-09 17:14:38 +02:00
Georg Semmler
20d02258fc Make Barrier RefUnwindSafe again
This commit manually implements `RefUnwindSafe` for
`std::sync::Barrier` to fix 146087. This is a fix for a regression
indroduced by e95db591a4
2025-09-09 17:13:38 +02:00
LorrensP-2158466
c4cbb54f3f add approx_delta to all gamma tests 2025-09-09 09:49:48 +02:00
bors
f13ef0d75d Auto merge of #146216 - LorrensP-2158466:miri-float-nondet-foreign-items-take2, r=RalfJung
Miri: non-deterministic floating point operations in foreign_items

Take 2 of rust-lang/rust#143906. The last 2 commits are what changed compared to the original pr.

Verified the tests using (fish shell):
```fish
env MIRIFLAGS="-Zmiri-max-extra-rounding-error -Zmiri-many-seeds" ./x miri --no-fail-fast std core coretests  -- f32 f64
```

r? `@RalfJung`
2025-09-07 10:46:38 +00:00
LorrensP-2158466
e7e06aca38 Change stdlib float tests to account for miri nondet floats. 2025-09-06 21:45:17 +02:00
ltdk
7ce8e289db Add Path::has_trailing_sep and related methods 2025-09-04 20:07:10 -04:00
bendn
f19da67ed7 add test 2025-09-04 14:17:31 +07:00
Stuart Cook
98f6887f35 Rollup merge of #145209 - hanna-kruppe:path_add_extension, r=tgross35
Stabilize `path_add_extension`

FCP in tracking issue rust-lang/rust#127292 finished in January. There was more discussion since then, but [libs-api decided to match `set_extension`][0] by keeping the return type as-is and adding a panic for invalid extensions. The latter was implemented in rust-lang/rust#140163, so this feature should be ready for stabilization. But if anyone's unsure, another FCP could be done to confirm.

Closes rust-lang/rust#127292

[0]: https://github.com/rust-lang/rust/issues/127292#issuecomment-2605197960
2025-09-04 10:01:52 +10:00
LorrensP-2158466
cfba491e67 fix 2025-08-31 10:03:49 +02:00
Stuart Cook
eda6dc9283 Rollup merge of #144651 - connortsui20:nonpoison_condvar, r=joboet
Implementation: `#[feature(nonpoison_condvar)]`

Tracking Issue: https://github.com/rust-lang/rust/issues/134645

This PR continues the effort made in https://github.com/rust-lang/rust/pull/144022 by adding the implementation of `nonpoison::condvar`.

Many of the changes here are similar to the changes made to implement `nonpoison::mutex`.

There are two other changes here. The first is that the `Barrier` implementation is migrated to use the `nonpoison::Condvar` instead of the `poison` variant. The second (which might be subject to some discussion) is that `WaitTimeoutResult` is moved up to `mod.rs`, as both `condvar` variants need that type (and I do not know if there is a better place to put it now).

### Related PRs

- `nonpoison_rwlock` implementation: https://github.com/rust-lang/rust/pull/144648
- `nonpoison_once` implementation: https://github.com/rust-lang/rust/pull/144653
2025-08-30 20:29:06 +10:00
Jacob Pratt
d5340c26fa Rollup merge of #145307 - connortsui20:lazylock-poison-msg, r=Amanieu
Fix `LazyLock` poison panic message

Fixes the issue raised in https://github.com/rust-lang/rust/pull/144872#issuecomment-3151100248

r? ```@Amanieu```
2025-08-23 23:58:35 -04:00
Connor Tsui
b2380d2bcc add nonpoison and poison condvar tests
Adds tests for the `nonpoison::Mutex` variant by using a macro to
duplicate the existing `poison` tests.

Note that all of the tests here are adapted from the existing `poison`
tests.

Also steals the `test_mutex_arc_condvar` test from `mutex.rs`.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23 09:20:44 -04:00
Connor Tsui
780319a75b stabilize unstable rwlock_downgrade feature
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-23 09:01:38 -04:00
Jacob Pratt
2bd39222cd Rollup merge of #144648 - connortsui20:nonpoison_rwlock, r=Mark-Simulacrum
Implementation: `#[feature(nonpoison_rwlock)]`

Tracking Issue: https://github.com/rust-lang/rust/issues/134645

This PR continues the effort made in https://github.com/rust-lang/rust/pull/144022 by adding the implementation of `nonpoison::rwlock`.

Many of the changes here are similar to the changes made to implement `nonpoison::mutex`. The only real difference is that this PR includes a reorganizing of the existing `poison::rwlock` file that hopefully makes both variants more readable.

### Related PRs

- `nonpoison_condvar` implementation: https://github.com/rust-lang/rust/pull/144651
- `nonpoison_once` implementation: https://github.com/rust-lang/rust/pull/144653
2025-08-22 22:00:46 -04:00
Connor Tsui
06eb782c4e modify LazyLock poison panic message
Fixes an issue where if the underlying `Once` panics because it is
poisoned, the panic displays the wrong message.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
2025-08-22 14:59:34 -04:00
Stuart Cook
d0fa5c7af7 Rollup merge of #144960 - raoulstrackx:raoul/rte-513-disable_sleep_tests_on_sgx, r=Mark-Simulacrum
[RTE-513] Ignore sleep_until test on SGX

rust-lang/rust#141829 added a test for `sleep_until`: it checks whether its specification holds:
> Puts the current thread to sleep until the specified deadline has passed.

but in SGX there's no secure time source. There's only the ability to request the `insecure_time` from outside of the enclave through a [usercall](https://github.com/fortanix/rust-sgx/blob/master/intel-sgx/fortanix-sgx-abi/src/lib.rs#L590-L592) and the ability to [wait](https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/sgx/abi/usercalls/mod.rs#L173-L179) for a certain event or timeout. But both are under the control of an attacker; users should not depend on the accuracy nor correctness of this time. We try to even enforce this by adding a +/-10% time interval to wait usercalls.

The current `thread::sleep_until` implementation uses this `wait` usercall. When a negative randomization interval is added to the timeout passed in `wait`, the test fails. As users should not rely on the correctness of any time inside the enclave, it should be considered an incorrect test on SGX. This PR ignores this test.
2025-08-19 14:18:21 +10:00
Josh Triplett
1ae4a0cc34 library: Migrate from cfg_if to cfg_select
Migrate the standard library from using the external `cfg_if` crate to
using the now-built-in `cfg_select` macro.

This does not yet eliminate the dependency from
`library/std/Cargo.toml`, because while the standard library itself no
longer uses `cfg_if`, it also incorporates the `backtrace` crate, which
does.

Migration assisted by the following vim command (after selecting the
full `cfg_if!` invocation):

```
'<,'>s/\(cfg_if::\)\?cfg_if/cfg_select/ | '<,'>s/^\( *\)} else {/\1}\r\1_ => {/c | '<,'>s/^\( *\)} else if #\[cfg(\(.*\))\] /\1}\r\1\2 => /e | '<,'>s/if #\[cfg(\(.*\))\] {/\1 => {/e
```

This is imperfect, but substantially accelerated the process. This
prompts for confirmation on the `} else {` since that can also appear
inside one of the arms. This also requires manual intervention to handle
any multi-line conditions.
2025-08-16 05:28:31 -07:00
Hanna Kruppe
52063ae248 stabilize path_add_extension 2025-08-13 19:03:13 +02:00
Jakub Beránek
ff44871be5 Rollup merge of #144870 - Kivooeo:file_prefix-stabilize, r=tgross35
Stabilize `path_file_prefix` feature

This stabilises `Path::file_prefix`, following the FCP in [tracking issue ](https://github.com/rust-lang/rust/issues/86319)

(FCP ended almost a year ago, so if it's needed for proccess we could rerun it)

Closes: https://github.com/rust-lang/rust/issues/86319
2025-08-13 07:03:47 +02:00
Esteban Küber
74c3727b1f Remove unnecessary parentheses in assert!s 2025-08-10 21:59:04 +00:00
Connor Tsui
ad499d076a add nonpoison and poison rwlock tests
Adds tests for the `nonpoison::RwLock` variant by using a macro to
duplicate the existing `poison` tests.

Note that all of the tests here are adapted from the existing `poison`
tests.
2025-08-09 08:41:27 +02:00
Connor Tsui
d8a0df075d reorganize rwlock tests
This commit simply helps discern the actual changes needed to test both
poison and nonpoison `rwlock`s.
2025-08-09 08:41:27 +02:00
Jakub Beránek
8fcfbcd868 Revert "Rollup merge of #143906 - LorrensP-2158466:miri-float-nondet-foreign-items, r=RalfJung"
This reverts commit 71f04692c3, reversing
changes made to 995ca3e532.
2025-08-08 19:16:48 +02:00
Stuart Cook
71f04692c3 Rollup merge of #143906 - LorrensP-2158466:miri-float-nondet-foreign-items, r=RalfJung
Miri: non-deterministic floating point operations in `foreign_items`

Part of [rust-lang/miri/#3555](https://github.com/rust-lang/miri/issues/3555#issue-2278914000), this pr does the `foreign_items` work.

Some things have changed since rust-lang/rust#138062 and rust-lang/rust#142514. I moved the "helpers" used for creating fixed outputs and clamping operations to their defined ranges to `math.rs`. These are now also extended to handle the floating-point operations in `foreign_items`. Tests in `miri/tests/float.rs` were changed/added.

Failing tests in `std` were extracted, run under miri with `-Zmiri-many-seeds=0..1000` and changed accordingly. Double checked with `-Zmiri-many-seeds`.

I noticed that the C standard doesn't specify the output ranges for all of its mathematical operations; it just specifies them as:
```
Returns
The sinh functions return sinh x.
```
So I used [Wolfram|Alpha](https://www.wolframalpha.com/).
2025-08-07 20:49:41 +10:00
LorrensP-2158466
71add2f5f7 Change stdlib float tests to account for miri nondet floats. 2025-08-06 17:21:04 +02:00
Raoul Strackx
3a993a611c Ignore sleep_until test on SGX 2025-08-05 14:51:39 +02:00
Kivooeo
4c4b8b23c6 remove gate 2025-08-04 02:18:18 +05:00
Connor Tsui
d073d297b6 add extra drop, panic, and unwind tests 2025-07-29 10:44:36 +02:00
Connor Tsui
3eb722e655 add nonpoison and poison mutex tests
Adds tests for the `nonpoison::Mutex` variant by using a macro to
duplicate the existing `poison` tests.

Note that all of the tests here are adapted from the existing `poison`
tests.
2025-07-29 10:36:26 +02:00
Connor Tsui
f34fb05923 reorder mutex tests
This commit simply helps discern the actual changes needed to test both
poison and nonpoison locks.
2025-07-29 10:33:05 +02:00
bors
ca98d4d4b3 Auto merge of #141829 - dvdsk:sleep_until_linux, r=cuviper,RalfJung
Specialize sleep_until implementation for unix (except mac)

related tracking issue: https://github.com/rust-lang/rust/issues/113752
Supersedes https://github.com/rust-lang/rust/pull/118480 for the reasons see: https://github.com/rust-lang/rust/issues/113752#issuecomment-2902594469

Replaces the generic catch all implementation with target_os specific ones for: linux/netbsd/freebsd/android/solaris/illumos etc. Other platforms like wasi, macos/ios/tvos/watchos and windows will follow in later separate PR's (once this is merged).
2025-07-06 23:00:51 +00:00
dvdsk
f24ee2c9b1 sleep_until: use clock_nanosleep where possible
Using clock nanosleep leads to more accurate sleep times on platforms
where it is supported.

To enable using clock_nanosleep this makes `sleep_until` platform
specific. That unfortunatly requires identical placeholder
implementations for the other platforms (windows/mac/wasm etc).

we will land platform specific implementations for those later. See the
`sleep_until` tracking issue.

This requires an accessors for the Instant type. As that accessor is only
used on the platforms that have clock_nanosleep it is marked as allow_unused.

32bit time_t targets do not use clock_nanosleep atm, they instead rely
on the same placeholder as the other platforms. We could make them
use clock_nanosleep too in the future using `__clock_nanosleep_time64`.

__clock_nanosleep_time64 is documented at:
https://www.gnu.org/software/libc/manual/html_node/64_002dbit-time-symbol-handling.html
2025-07-06 17:36:49 +02:00
klensy
c76d032f01 setup CI and tidy to use typos for spellchecking and fix few typos 2025-07-03 10:51:06 +03:00
Folkert de Vries
1dfc8406dc make tidy-alphabetical use a natural sort 2025-06-25 22:52:38 +02:00