Commit Graph

6874 Commits

Author SHA1 Message Date
bors
c602e9aeaa Auto merge of #133160 - jhpratt:rollup-wzj9q15, r=jhpratt
Rollup of 4 pull requests

Successful merges:

 - #132934 (Overhaul the `-l` option parser (for linking to native libs))
 - #133142 (rename rustc_const_stable_intrinsic -> rustc_intrinsic_const_stable_indirect)
 - #133145 (Document alternatives to `static mut`)
 - #133158 (Subtree update of `rust-analyzer`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-18 12:46:07 +00:00
bors
e83c45a98b Auto merge of #128219 - connortsui20:rwlock-downgrade, r=tgross35
Rwlock downgrade

Tracking Issue: #128203

This PR adds a `downgrade` method for `RwLock` / `RwLockWriteGuard` on all currently supported platforms.

Outstanding questions:
- [x] ~~Does the `futex.rs` change affect performance at all? It doesn't seem like it will but we can't be certain until we bench it...~~
- [x] ~~Should the SOLID platform implementation [be ported over](https://github.com/rust-lang/rust/pull/128219#discussion_r1693470090) to the `queue.rs` implementation to allow it to support downgrades?~~
2024-11-18 07:24:12 +00:00
Kornel
8b43a7ee5d
Document alternatives to static mut 2024-11-18 00:34:06 +00:00
Connor Tsui
fc52cdd9a8 reduce threads in downgrade test 2024-11-16 12:31:14 -05:00
Connor Tsui
782b07e1ff fix DOWNGRADED bit unpreserved
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-11-16 12:31:14 -05:00
Connor Tsui
84fd95cbed fix memory ordering bug + bad test
This commit fixes a memory ordering bug in the futex implementation
(`Relaxed` -> `Release` on `downgrade`).

This commit also removes a badly written test that deadlocked and
replaces it with a more reasonable test based on an already-tested
`downgrade` test from the parking-lot crate.
2024-11-16 12:31:14 -05:00
Connor Tsui
3d191b50d2 add safety comments for queue implementation 2024-11-16 12:31:13 -05:00
Connor Tsui
26b5a1485e add downgrade to queue implementation
This commit adds the `downgrade` method onto the inner `RwLock` queue
implementation.

There are also a few other style patches included in this commit.

Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-11-16 12:31:13 -05:00
Connor Tsui
31e35c2131 modify queue implementation documentation
This commit only has documentation changes and a few things moved around
the file. The very few code changes are cosmetic: changes like turning a
`match` statement into an `if let` statement or reducing indentation for
long if statements.

This commit also adds several safety comments on top of `unsafe` blocks
that might not be immediately obvious to a first-time reader.

Code "changes" are in:
- `add_backlinks_and_find_tail`
- `lock_contended`

A majority of the changes are just expanding the comments from 80
columns to 100 columns.
2024-11-16 12:31:13 -05:00
Connor Tsui
fa9f04af5d add downgrade to futex implementation 2024-11-16 12:31:13 -05:00
Connor Tsui
3336ae0838 add simple downgrade implementations 2024-11-16 12:31:13 -05:00
Connor Tsui
f71ecc48cc add downgrade method onto RwLockWriteGuard 2024-11-16 12:31:13 -05:00
Connor Tsui
b683e1dc13 add RwLock downgrade tests 2024-11-16 12:31:13 -05:00
Jubilee
a5510a5430
Rollup merge of #132984 - sunshowers:pipe2, r=tgross35
[illumos] use pipe2 to create anonymous pipes

pipe2 allows the newly-created pipe to atomically be CLOEXEC.

pipe2 was added to illumos a long time ago:
5dbfd19ad5. I've verified that this change passes all of std's tests on illumos.
2024-11-14 17:55:25 -08:00
Jubilee
3f9f7c4a72
Rollup merge of #132977 - cberner:fix_solaris, r=tgross35
Fix compilation error on Solaris due to flock usage

PR 130999 added the file_lock feature, but libc does not define flock() for the Solaris platform leading to a compilation error.

Additionally, I went through all the Tier 2 platforms and read through their documentation to see whether flock was implemented. This turned up 5 more Unix platforms where flock is not supported, even though it may exist in the libc crate.

Fixes https://github.com/rust-lang/rust/issues/132921

Related to #130999
2024-11-14 17:55:25 -08:00
Jubilee
b1b56b11a2
Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviper
Add as_slice/into_slice for IoSlice/IoSliceMut.

ACP: https://github.com/rust-lang/libs-team/issues/93

Tracking issue: #132818

Based on a623c5233ae7f6b540e5c00f2be02f40b33b0793 (CC `@mpdn)` and #111277 (CC `@Lucretiel).`

Closes: #124659

Tracking Issue: TODO

try-job: test-various
try-job: dist-various-1
try-job: dist-various-2

r? libs
2024-11-14 17:55:24 -08:00
Guillaume Gomez
e6cd8699ea
Rollup merge of #133027 - no1wudi:master, r=jhpratt
Fix a copy-paste issue in the NuttX raw type definition

This file is copied from the rtems as initial implementation, and forgot to change the OS name in the comment.
2024-11-14 18:26:16 +08:00
Huang Qi
79e2af285a Fix a copy-paste issue in the NuttX raw type definition
This file is copied from the rtems as initial implementation, and
forgot to change the OS name in the comment.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-11-14 14:50:30 +08:00
Jubilee
17dcadd587
Rollup merge of #133003 - zachs18:clonetouninit-dyn-compat-u8, r=dtolnay
Make `CloneToUninit` dyn-compatible

Make `CloneToUninit` dyn-compatible, by making `clone_to_uninit`'s `dst` parameter `*mut u8` instead of `*mut Self`, so the method does not reference `Self` except in the `self` parameter and is thus dispatchable from a trait object.

This allows, among other things, adding `CloneToUninit` as a supertrait bound for `trait Foo` to allow cloning `dyn Foo` in some containers. Currently, this means that `Rc::make_mut` and `Arc::make_mut` can work with `dyn Foo` where `trait Foo: CloneToUninit`.

<details><summary>Example</summary>

```rs
#![feature(clone_to_uninit)]
use std::clone::CloneToUninit;
use std::rc::Rc;
use std::fmt::Debug;
use std::borrow::BorrowMut;

trait Foo: BorrowMut<u32> + CloneToUninit + Debug {}

impl<T: BorrowMut<u32> + CloneToUninit + Debug> Foo for T {}

fn main() {
    let foo: Rc<dyn Foo> = Rc::new(42_u32);
    let mut bar = foo.clone();
    *Rc::make_mut(&mut bar).borrow_mut() = 37;
    dbg!(foo, bar); // 42, 37
}
```

</details>

Eventually, `Box::<T>::clone` is planned to be converted to use `T::clone_to_uninit`, which when combined with this change, will allow cloning `Box<dyn Foo>` where `trait Foo: CloneToUninit` without any additional `unsafe` code for the author of `trait Foo`.[^1]

This PR should have no stable side-effects, as `CloneToUninit` is unstable so cannot be mentioned on stable, and `CloneToUninit` is not used as a supertrait anywhere in the stdlib.

This change removes some length checks that could only fail if library UB was already hit (e.g. calling `<[T]>::clone_to_uninit` with a too-small-length `dst` is library UB and was previously detected[^2]; since `dst` does not have a length anymore, this now cannot be detected[^3]).

r? libs-api

-----

I chose to make the parameter `*mut u8` instead of `*mut ()` because that might make it simpler to pass the result of `alloc` to `clone_to_uninit`, but `*mut ()` would also make sense, and any `*mut ConcreteType` would *work*. The original motivation for [using specifically `*mut ()`](https://github.com/rust-lang/rust/pull/116113#discussion_r1335303908) appears to be `std::ptr::from_raw_parts_mut`, but that now [takes `*mut impl Thin`](https://doc.rust-lang.org/nightly/std/ptr/fn.from_raw_parts.html) instead of `*mut ()`. I have another branch where the parameter is `*mut ()`, if that is preferred.

It *could* also take something like `&mut [MaybeUninit<u8>]` to be dyn-compatible but still allow size-checking and in some cases safe writing, but this is already an `unsafe` API where misuse is UB, so I'm not sure how many guardrails it's worth adding here, and `&mut [MaybeUninit<u8>]` might be overly cumbersome to construct for callers compared to `*mut u8`

[^1]:  Note that  `impl<T: CloneToUninit + ?Sized> Clone for Box` must be added before or at the same time as when `CloneToUninit` becomes stable, due to `Box` being `#[fundamental]`, as if there is any stable gap between the stabilization of `CloneToUninit` and `impl<T: CloneToUninit + ?Sized> Clone for Box`, then users could implement both `CloneToUninit for dyn LocalTrait` and separately `Clone for Box<dyn LocalTrait>` during that gap, and be broken by the introduction of  `impl<T: CloneToUninit + ?Sized> Clone for Box`.

[^2]: Using a `debug_assert_eq` in [`core::clone::uninit::CopySpec::clone_slice`](https://doc.rust-lang.org/nightly/src/core/clone/uninit.rs.html#28).

[^3]: This PR just uses [the metadata (length) from `self`](e0c1c8bc50/library/core/src/clone.rs (L286)) to construct the `*mut [T]` to pass to `CopySpec::clone_slice` in `<[T]>::clone_to_uninit`.
2024-11-13 22:43:37 -08:00
Jubilee
52913653dd
Rollup merge of #131304 - RalfJung:float-core, r=tgross35
float types: move copysign, abs, signum to libcore

These operations are explicitly specified to act "bitwise", i.e. they just act on the sign bit and do not even quiet signaling NaNs. We also list them as ["non-arithmetic operations"](https://doc.rust-lang.org/nightly/std/primitive.f32.html#nan-bit-patterns), and all the other non-arithmetic operations are in libcore. There's no reason to expect them to require any sort of runtime support, and from [these experiments](https://github.com/rust-lang/rust/issues/50145#issuecomment-997301250) it seems like LLVM indeed compiles them in a way that does not require any sort of runtime support.

Nominating for `@rust-lang/libs-api` since this change takes immediate effect on stable.

Part of https://github.com/rust-lang/rust/issues/50145.
2024-11-13 22:43:35 -08:00
Christopher Berner
0df3ef4435 Fix compilation error on Solaris due to flock usage
PR 130999 added the file_lock feature, but libc does not define
flock() for the Solaris platform leading to a compilation error.

Additionally, I went through all the Tier 2 platforms and read through
their documentation to see whether flock was implemented. This turned up
5 more Unix platforms where flock is not supported, even though it may
exist in the libc crate.
2024-11-13 06:53:19 -08:00
Rain
fb3edb2fc7 [illumos] use pipe2 to create anonymous pipes
pipe2 allows the newly-created pipe to atomically be CLOEXEC.

pipe2 was added to illumos a long time ago:
5dbfd19ad5.
I've verified that this change passes all tests.
2024-11-13 05:48:06 +00:00
Zachary S
e0c1c8bc50 Make CloneToUninit dyn-compatible 2024-11-12 15:08:41 -06:00
Matthias Krüger
0555bb2a1b
Rollup merge of #132869 - lolbinarycat:library-fix-too_long_first_doc_paragraph, r=tgross35
split up the first paragraph of doc comments for better summaries

used `./x clippy -Aclippy::all '-Wclippy::too_long_first_doc_paragraph' library/core library/alloc` to find these issues.
2024-11-12 06:27:19 +01:00
bors
67f21277cd Auto merge of #132919 - matthiaskrgr:rollup-ogghyvp, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #120077 (Add Set entry API )
 - #132144 (Arbitrary self types v2: (unused) Receiver trait)
 - #132297 (Document some `check_expr` methods, and other misc `hir_typeck` tweaks)
 - #132820 (Add a default implementation for CodegenBackend::link)
 - #132881 (triagebot: Autolabel rustdoc book)
 - #132912 (Simplify some places that deal with generic parameter defaults)
 - #132916 (Unvacation fmease)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-11-12 02:51:21 +00:00
Matthias Krüger
3ab4477ba7
Rollup merge of #120077 - SUPERCILEX:set-entry, r=Amanieu
Add Set entry API

See https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/HashSet.3A.3Aentry/near/413224639 and https://github.com/rust-lang/rust/issues/60896#issuecomment-678708111

Closes https://github.com/rust-lang/rfcs/issues/1490
2024-11-11 21:58:28 +01:00
Matthias Krüger
95175f851e
Rollup merge of #130999 - cberner:flock_pr, r=joboet
Implement file_lock feature

This adds lock(), lock_shared(), try_lock(), try_lock_shared(), and unlock() to File gated behind the file_lock feature flag

This is the initial implementation of https://github.com/rust-lang/rust/issues/130994 for Unix and Windows platforms. I will follow it up with an implementation for WASI preview 2
2024-11-11 15:23:33 +01:00
binarycat
ae3c68db34 split up the first paragraph of doc comments for better summaries 2024-11-10 13:22:58 -06:00
Alona Enraght-Moony
c496af64ed Add as_slice/into_slice for IoSlice/IoSliceMut.
Co-authored-by: Mike Pedersen <mike@mikepedersen.dk>
Co-authored-by: Nathan West <Lucretiel@gmail.com>
2024-11-09 18:52:29 +00:00
Jubilee
dc647392d6
Rollup merge of #132778 - lolbinarycat:io-Error-into_inner-docs, r=cuviper
update io::Error::into_inner to acknowledge io::Error::other
2024-11-08 20:46:13 -08:00
binarycat
b004cac72e update io::Error::into_inner to acknowlage io::Error::other 2024-11-08 10:43:34 -06:00
Christopher Berner
9330786c27 Address review comments 2024-11-08 08:16:41 -08:00
Christopher Berner
5a156a7999
Update library/std/src/sys/pal/windows/fs.rs
Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2024-11-08 08:09:53 -08:00
Stuart Cook
4b904ceb46
Rollup merge of #132738 - cuviper:channel-heap-init, r=ibraheemdev
Initialize channel `Block`s directly on the heap

The channel's `Block::new` was causing a stack overflow because it held
32 item slots, instantiated on the stack before moving to `Box::new`.
The 32x multiplier made modestly-large item sizes untenable.

That block is now initialized directly on the heap.

Fixes #102246

try-job: test-various
2024-11-08 18:51:30 +11:00
Jubilee
c9009ae8c8
Rollup merge of #132696 - fortanix:raoul/rte-235-fix_fmodl_missing_symbol_issue, r=tgross35
Compile `test_num_f128` conditionally on `reliable_f128_math` config

With #132434 merged, our internal SGX CI started failing with:
```
05:27:34   = note: rust-lld: error: undefined symbol: fmodl
05:27:34           >>> referenced by arith.rs:617 (core/src/ops/arith.rs:617)
05:27:34           >>>               /home/jenkins/workspace/rust-sgx-ci/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-fortanix-unknown-sgx/release/deps/std-5d5f11eb008c9091.std.d8141acc61ab7ac8-cgu.10.rcgu.o:(std::num::test_num::h7dd9449f6c01fde8)
05:27:34           >>> did you mean: fmodf
05:27:34           >>> defined in: /home/jenkins/workspace/rust-sgx-ci/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-fortanix-unknown-sgx/release/deps/libcompiler_builtins-0376f439a2ebf305.rlib(compiler_builtins-0376f439a2ebf305.compiler_builtins.c22db39d25d6f802-cgu.148.rcgu.o)
```
This originated from the `test_num_f128` test not having the required conditional compilation. This PR fixes that issue.

cc: ````@jethrogb,```` ````@workingjubilee````
2024-11-07 18:48:23 -08:00
Josh Stone
03383ad102 Initialize channel Blocks directly on the heap
The channel's `Block::new` was causing a stack overflow because it held
32 item slots, instantiated on the stack before moving to `Box::new`.
The 32x multiplier made modestly-large item sizes untenable.

That block is now initialized directly on the heap.

Fixes #102246
2024-11-07 10:09:45 -08:00
bors
9a77c3c2cb Auto merge of #132714 - mati865:update-memchr, r=tgross35
unpin and update memchr

I'm unable to build x86_64-pc-windows-gnu Rust due to some weird binutils bug, but thinlto issue seems to be no longer present. Let's give it a go on the CI.
Possibly fixed by https://github.com/rust-lang/rust/pull/129079

Fixes #127890
2024-11-07 15:34:14 +00:00
Jonas Böttiger
0a0cadfe8a
Rollup merge of #132715 - tabokie:fix-lazy-lock-doc, r=Noratrieb
fix `LazyLock::get` and `LazyLock::get_mut` document
2024-11-07 13:08:29 +01:00
Raoul Strackx
072088074e Separate f128 % operation to deal with missing fmodl symbol 2024-11-07 11:33:10 +01:00
Xinye
557c7f8cdd fix lazylock comment
Signed-off-by: Xinye <xinye.tao@metabit-trading.com>
2024-11-07 10:51:00 +08:00
bors
775f6d8d9d Auto merge of #131888 - ChrisDenton:deopt, r=ibraheemdev
Revert using `HEAP` static in Windows alloc

Fixes #131468

This does the minimum to remove the `HEAP` static that was causing chromium issues. It would be worth having a more substantial look at this module but for now I think this addresses the immediate issue.

cc `@danakj`
2024-11-07 01:23:47 +00:00
Mateusz Mikuła
7cdbb59c26 unpin and update memchr 2024-11-07 02:09:39 +01:00
Guillaume Gomez
d6a43d4724
Rollup merge of #132617 - uellenberg:fix-rendered-doc, r=cuviper
Fix an extra newline in rendered std doc

Fixes #132564

![17308581942254367500907812250579](https://github.com/user-attachments/assets/9e946c49-c0a6-40ba-ab69-b80fe0e085e1)
(taken from the issue above)

The problem with the formatting is due to that newline between `<code>` and `<svg>`. Any newlines outside of the code (i.e., within elements inside of it) are fine.
2024-11-07 02:09:51 +08:00
uellenberg
934be9b63b Change some code blocks to quotes in rendered std doc
Fixes #132564
2024-11-05 16:11:47 -08:00
NotWearingPants
107b4fdba2
docs: fix grammar in doc comment at unix/process.rs 2024-11-04 20:42:21 +02:00
bors
706eec8ce1 Auto merge of #132434 - tgross35:f128-tests, r=workingjubilee
Update `compiler-builtins` and enable f128 tests on all non-buggy platforms

Update compiler_builtins to 0.1.138 and pin it. This updates to a new version of builtins that includes [1], which was
the last blocker to us enabling `f128` tests on all platforms.

With that, we now provide symbols necessary to work with `f128` everywhere. This means that we are no longer restricted to systems that provide `f128` symbols themselves, and can enable tests by default.

There are still a handful of platforms that need to remain disabled because of bugs and some that had to get updated.

Math support is still off by default since those symbols are not yet available.

[1]: https://github.com/rust-lang/compiler-builtins/pull/624

try-job: test-various
try-job: i686-gnu-nopt
2024-11-04 04:03:29 +00:00
Trevor Gross
c0fc25cc20 Enable f128 tests on all non-buggy platforms 🎉
With the `compiler-builtins` update to 0.1.137 [1], we now provide
symbols necessary to work with `f128` everywhere. This means that we are
no longer restricted to 64-bit linux, and can enable tests by default.

There are still a handful of platforms that need to remain disabled
because of bugs. This patch additionally disables the following:

1. MIPS [2]
2. 32-bit x86 [3]

Math support is still off by default since those symbols are not yet
available.

[1]: https://github.com/rust-lang/rust/pull/132433
[2]: https://github.com/llvm/llvm-project/issues/96432
[3]: https://github.com/llvm/llvm-project/issues/77401
2024-11-03 19:33:04 -06:00
Trevor Gross
95ecf0c262 Update compiler_builtins to 0.1.138 and pin it
This updates to a new version of builtins that includes [1], which was
the last blocker to us enabling `f128` tests on all platforms 🎉.

With this update, also change to pinning the version with `=` rather
than using the default carat versioning. This is meant to ensure that
`compiler-builtins` does not get updated as part of the weekly
`Cargo.lock` update, since updates to this crate need to be intentional:
changes to rust-lang/rust and rust-lang/compiler-builtins sometimes need
to be kept in lockstep, unlike most dependencies, and sometimes these
updates can be problematic.

[1]: https://github.com/rust-lang/compiler-builtins/pull/624
2024-11-03 17:43:16 -06:00
bors
42188c3ca8 Auto merge of #123723 - madsmtm:apple-std-os, r=dtolnay
Make `std::os::darwin` public

I'm not sure of the reasoning behind them not being public before, but I think they should be, just like `std::os::ios` and `std::os::macos` are public.

Additionally, I've merged their source code, as it was otherwise just a bunch of unnecessary duplication.

Ultimately, I've done this PR to fix `./x build library --target=aarch64-apple-tvos,aarch64-apple-watchos,aarch64-apple-visionos`, as that currently fails because of dead code warnings.

Since you reviewed https://github.com/rust-lang/rust/pull/121419
r? davidtwco

Fixes https://github.com/rust-lang/rust/issues/121640.

`@rustbot` label O-tvos O-watchos O-visionos
2024-11-03 22:25:11 +00:00
Matthias Krüger
e9379382f9
Rollup merge of #132503 - RalfJung:const-hash-map, r=Amanieu
better test for const HashMap; remove const_hash leftovers

The existing `const_with_hasher` test is kind of silly since the HashMap it constructs can never contain any elements. So this adjusts the test to construct a usable HashMap, which is a bit non-trivial since the default hash builder cannot be built in `const`. `BuildHasherDefault::new()` helps but is unstable (https://github.com/rust-lang/rust/issues/123197), so we also have a test that does not involve that type.

The second commit removes the last remnants of https://github.com/rust-lang/rust/issues/104061, since they aren't actually useful -- without const traits, you can't do any hashing in `const`.

Cc ``@rust-lang/libs-api`` ``@rust-lang/wg-const-eval``
Closes #104061
Related to https://github.com/rust-lang/rust/issues/102575
2024-11-03 12:08:52 +01:00