Commit Graph

8016 Commits

Author SHA1 Message Date
Matthias Krüger
82fbbddf63 Rollup merge of #143925 - oli-obk:slice-const-partialeq, r=fee1-dead
Make slice comparisons const

This needed a fix for `derive_const`, too, as it wasn't usable in libcore anymore as trait impls need const stability attributes. I think we can't use the same system as normal trait impls while `const_trait_impl` is still unstable.

r? ```@fee1-dead```

cc rust-lang/rust#143800
2025-07-18 14:49:19 +02:00
Oli Scherer
250648e871 Make derive_const usable within libcore again
Also make it *only* usable on nightly
2025-07-17 15:42:54 +00:00
León Orell Valerian Liehr
7e041c46f7 Rollup merge of #144002 - martinomburajr:patch-1, r=ibraheemdev
Update poison.rs

Typo in word "below" previously "bellow"
2025-07-17 03:58:35 +02:00
León Orell Valerian Liehr
36a362bff5 Rollup merge of #143856 - mladedav:dm/private-reexport, r=petrochenkov
Linting public reexport of private dependencies

Part of public/private dependencies rust-lang/rust#44663
Partially addresses rust-lang/rust#71043

I'm adding a warning for reexports of private dependencies into `rustc_resolve`. I get that this should not be a warning, but should instead be a lint to be controlled by the feature gate, but I did not figure out how exactly to do that at that point. I tried doing the same thing as is done in `rustc_privacy`, but the linting system is not ready yet as far as I understand the error I got, so I made a warning for now instead. Some guidance on how to emit lints with `dcx` would be appreciated.

This also sets the `std_detect` crate as a public dependency of `std` because some macros are reexported from there. I did not check closer, but the other option may be to allow the specific reexports instead.
2025-07-17 03:58:33 +02:00
León Orell Valerian Liehr
b9fd2bccfa Rollup merge of #143829 - a1phyr:trim_borrowed_buf, r=ChrisDenton
Trim `BorrowedCursor` API

This PR removes some method from the unstable `BorrowedCursor` type. A rational for each change can be found in the message of each commit.

I don't think that an ACP is required for this, please tell me if it is not the case.

Cc rust-lang/rust#78485 rust-lang/rust#117693
2025-07-17 03:58:32 +02:00
León Orell Valerian Liehr
2f879530d2 Rollup merge of #143592 - ChrisDenton:uwp-link, r=Mark-Simulacrum
UWP: link ntdll functions using raw-dylib

Lazy loading isn't necessary so there's no need for the added complexity and overhead. However, it may be that people using UWP rust libraries don't have the necessary import libraries linked by Visual Studio so this uses raw-dylib, which allows linking to DLL functions without having an import library. This is a somewhat temporary situation as raw-dylib is intended to eventually be the default for all imports. When that happens, this special case can be removed.

Closes rust-lang/rust#143530
2025-07-17 03:58:29 +02:00
Martin Ombura Jr.
f1d84468c8 Update poison.rs
Typo in word "below"
2025-07-15 20:07:03 -07:00
Cameron Steffen
1120cb2fe5 Add LocalKey<Cell>::update 2025-07-15 16:17:57 -05:00
David Mládek
d627e252ae make std_detect public dependency of std 2025-07-15 15:44:26 +02:00
Samuel Tardieu
2e37e24179 Rollup merge of #143910 - ChrisDenton:no-symbolization, r=tgross35
Add experimental `backtrace-trace-only` std feature

This experimentally allows building std with backtrace but without symbolisation. It does not affect stable and requires build-std to use. This doesn't change the backtrace crate itself so relies on the optimizer to remove the unused parts.

Example usage:

```toml
# .cargo/config.toml
[unstable]
build-std = ["core", "alloc", "panic_unwind", "std"]
build-std-features = ["backtrace", "backtrace-trace-only", "panic-unwind"]
```

```toml
# Cargo.toml
[profile.release]
opt-level = 3
lto = "thin"
codegen-units = 1
```

Ideally we should split the backtrace feature into `backtrace-trace` and `backtrace-symbolize` (with the latter dependent on the former) because Cargo features tend to work better when they're positive rather than negative. But I'm keen for this experiment not to break existing users.

cc ``@joshtriplett``
2025-07-15 12:52:42 +02:00
Samuel Tardieu
30b46e3f8c Rollup merge of #143710 - joshtriplett:random-updates, r=joshtriplett
Updates to random number generation APIs

Updates based on discussions about random number generation.

- Add comment on `RandomSource::fill_bytes` about multiple calls, to allow
  efficient implementations for random sources that generate a word at a time.

- Drop the `Random` trait in favor of `Distribution<T>`, which will let people
  make calls like random(1..=6), and which allows for future expansion to
  non-uniform distributions, as well as floating-point. (For now, this is only
  implemented for `RangeFull`, to get the interface in place. Subsequent PRs
  will implement it for other range types.)
2025-07-14 18:05:44 +02:00
Samuel Tardieu
74b5ac5c15 Rollup merge of #141809 - ChrisDenton:no-cleaup, r=jhpratt
Don't call WSACleanup on process exit

This isn't necessary as cleanup will happen when the process exits regardless.

fixes rust-lang/rust#141799
2025-07-14 18:05:43 +02:00
Chris Denton
c8fb37a521 Don't call WSACleanup on process exit 2025-07-14 14:27:49 +00:00
Chris Denton
9fd3886838 Add experimental backtrace-trace-only std feature 2025-07-14 11:52:17 +00:00
Jakub Beránek
70301da7c7 Rollup merge of #143881 - orlp:once-state-repr, r=tgross35
Use zero for initialized Once state

By re-labeling which integer represents which internal state for `Once` we can ensure that the initialized state is the all-zero state. This is beneficial because some CPU architectures (such as Arm) have specialized instructions to specifically branch on non-zero, and checking for the initialized state is by far the most important operation.

As an example, take this:

```rust
use std::sync::atomic::{AtomicU32, Ordering};

const INIT: u32 = 3;

#[inline(never)]
#[cold]
pub fn slow(state: &AtomicU32) {
    state.store(INIT, Ordering::Release);
}

pub fn ensure_init(state: &AtomicU32) {
    if state.load(Ordering::Acquire) != INIT {
        slow(state)
    }
}
```

If `INIT` is 3 (as is currently the state for `Once`), we see the following assembly on `aarch64-apple-darwin`:

```asm
example::ensure_init::h332061368366e313:
        ldapr   w8, [x0]
        cmp     w8, #3
        b.ne    LBB1_2
        ret
LBB1_2:
        b       example::slow::ha042bd6a4f33724e
```

By changing the `INIT` state to zero we get the following:

```asm
example::ensure_init::h332061368366e313:
        ldapr   w8, [x0]
        cbnz    w8, LBB1_2
        ret
LBB1_2:
        b       example::slow::ha042bd6a4f33724e
```

So this PR saves 1 instruction every time a `LazyLock` gets accessed on platforms such as these.
2025-07-14 11:04:55 +02:00
Orson Peters
f041962694 Add comment why we use zero for COMPLETE 2025-07-13 12:37:34 +02:00
Orson Peters
a2d4139336 Use zero for initialized Once state 2025-07-13 12:16:40 +02:00
Josh Triplett
377aa764aa Attempt to fix up SGX for random API updates 2025-07-13 02:54:27 -07:00
León Orell Valerian Liehr
5d5645972f Rollup merge of #143776 - no1wudi:fix, r=tgross35
std: move NuttX to use arc4random for random number generation

arc4random support in libc merged in https://github.com/rust-lang/libc/pull/4464, so:

* Move `target_os = "nuttx"` from unix_legacy to arc4random section
* This aligns NuttX with other POSIX-compliant systems that support arc4random
* Improves random number generation quality on NuttX by using the system's built-in arc4random implementation instead of legacy fallback methods

NuttX supports arc4random_buf which provides better entropy and security compared to the legacy random number generation methods.
2025-07-13 07:21:19 +02:00
bors
915e535244 Auto merge of #143810 - matthiaskrgr:rollup-iw7a23z, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#143403 (Port several trait/coherence-related attributes the new attribute system)
 - rust-lang/rust#143633 (fix: correct assertion to check for 'noinline' attribute presence before removal)
 - rust-lang/rust#143647 (Clarify and expand documentation for std::sys_common dependency structure)
 - rust-lang/rust#143716 (compiler: doc/comment some codegen-for-functions interfaces)
 - rust-lang/rust#143747 (Add target maintainer information for aarch64-unknown-linux-musl)
 - rust-lang/rust#143759 (Fix typos in function names in the `target_feature` test)
 - rust-lang/rust#143767 (Bump `src/tools/x` to Edition 2024 and some cleanups)
 - rust-lang/rust#143769 (Remove support for SwitchInt edge effects in backward dataflow)
 - rust-lang/rust#143770 (build-helper: clippy fixes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-12 10:46:43 +00:00
Matthias Krüger
140fc184f2 Rollup merge of #143647 - ColtenOuO:master, r=ChrisDenton
Clarify and expand documentation for std::sys_common dependency structure

This PR makes a minor improvement to the module-level documentation of std::sys_common:

Replaces the lowercase “dag” with the more standard and explicit form “DAG (Directed Acyclic Graph)” for clarity.
2025-07-11 19:45:23 +02:00
Josh Triplett
5e203851f7 random: Provide a Distribution<T> trait
This will let people make calls like random(1..=6), and allows for
future expansion to non-uniform distributions, as well as
floating-point.

For now, this is only implemented for `RangeFull`, to get the interface
in place. Subsequent commits will implement it for other range types.
2025-07-11 10:21:34 -07:00
Huang Qi
074846289a std: move NuttX to use arc4random for random number generation
* Move `target_os = "nuttx"` from unix_legacy to arc4random section
* This aligns NuttX with other POSIX-compliant systems that support arc4random
* Improves random number generation quality on NuttX by using the system's
  built-in arc4random implementation instead of legacy fallback methods

NuttX supports arc4random_buf which provides better entropy and security
compared to the legacy random number generation methods.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2025-07-11 17:31:27 +08:00
Matthias Krüger
5cbf7cf9c4 Rollup merge of #143568 - Ayush1325:uefi-tcp4-timeout, r=tgross35
std: sys: net: uefi: tcp4: Add timeout support

- Implement timeout support for read, write and connect.
- A software implementation using Instant.
2025-07-11 07:35:19 +02:00
Matthias Krüger
2730bebbf8 Rollup merge of #142391 - LevitatingBusinessMan:setsid, r=workingjubilee
rust: library: Add `setsid` method to `CommandExt` trait

Add a setsid method to the CommandExt trait so that callers can create a process in a new session and process group whilst still using the POSIX spawn fast path.

Tracking issue: rust-lang/rust#105376

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

This PR was previously submitted by ``@HarveyHunt`` (whom I marked as Co-Author in the commit message) in rust-lang/rust#105377. However that PR went stale.

I applied the [suggestion](231d19fcbf (r1893457943)) to change the function signature to `fn setsid(&mut self, setsid: bool) -> &mut Command`.
2025-07-11 07:35:17 +02:00
Colten
3c11029ace docs: clarify “dag” in std::sys_common doc comment 2025-07-11 11:53:47 +08:00
Matthias Krüger
a17559bff5 Rollup merge of #143668 - biabbas:vxworks, r=Noratrieb
Fix VxWorks build errors

fixes rust-lang/rust#143442

r? ``@Noratrieb``
2025-07-10 15:19:33 +02:00
LevitatingBusinessMan (Rein Fernhout)
e0f76871ed rust: library: Add setsid method to CommandExt trait
Add a setsid method to the CommandExt trait so that callers can create
a process in a new session and process group whilst still using the
POSIX spawn fast path.

Co-Authored-By: Harvey Hunt <harveyhunt@fb.com>
2025-07-10 05:26:58 +02:00
Ayush Singh
d8273d3997 std: sys: net: uefi: tcp4: Add timeout support
- Implement timeout support for read, write and connect.
- A software implementation using Instant.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-09 22:38:12 +05:30
Oli Scherer
486ffda9dc Add opaque TypeId handles for CTFE 2025-07-09 16:37:11 +00:00
Benoît du Garreau
803b4d2622 core: Remove BorrowedCursor::init_ref method
This method was not really useful: at no point one would only need to
read the initialized part of the cursor without mutating it.
2025-07-09 18:11:26 +02:00
B I Mohammed Abbas
6637335845 Fix VxWorks build errors 2025-07-09 09:54:08 +05:30
Matthias Krüger
2554c424ef Rollup merge of #143340 - nabijaczleweli:awhile, r=mati865
awhile -> a while where appropriate
2025-07-07 19:55:32 +02:00
Chris Denton
2412f8921c UWP: link ntdll functions using raw-dylib 2025-07-07 15:39:31 +00:00
xizheyin
2765bd48f0 std: fix typo in std::path
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-07 15:20:22 +08: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
61cf174dce sleep_until: add clock_nanosleep support to Miri
The clock_nanosleep support is there to allow code using `sleep_until`
to run under Miri. Therefore the implementation is minimal.
- Only the clocks REALTIME and MONOTONIC are supported. The first is supported simply
because it was trivial to add not because it was needed for sleep_until.
- The only supported flag combinations are no flags or TIMER_ABSTIME only.
If an unsupported flag combination or clock is passed in this throws
unsupported.
2025-07-06 17:49:35 +02: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
Matthias Krüger
19f8ba4733 Rollup merge of #143470 - Ayush1325:uefi-tcp4-recv, r=joshtriplett
std: sys: net: uefi: tcp4: Implement read

- A blocking implementation of tcp4 read.
- Basically a copy of [write](https://github.com/rust-lang/rust/pull/141532)
2025-07-06 10:03:22 +02:00
Jubilee
2f119daf4e Rollup merge of #143086 - SciMind2460:patch-2, r=workingjubilee
Update poison.rs to fix the typo (sys->sync)
2025-07-04 23:26:20 -07:00
Ayush Singh
1f01d9b3db std: sys: net: uefi: tcp4: Implement read
A blocking implementation of tcp4 read.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-05 11:10:38 +05:30
Matthias Krüger
edfaaeb397 Rollup merge of #141532 - Ayush1325:uefi-tcp4-send, r=tgross35
std: sys: net: uefi: tcp4: Implement write

A blocking implementation of tcp4 write.
2025-07-05 00:12:08 +02:00
Ayush Singh
f4ef1a769a std: sys: net: uefi: tcp4: Implement write
A blocking implementation of tcp4 write.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-07-04 21:53:16 +05:30
Matthias Krüger
2faf66d091 Rollup merge of #143387 - dpaoliello:shouldpanicfn, r=bjorn3
Make __rust_alloc_error_handler_should_panic a function

Fixes rust-lang/rust#143253

`__rust_alloc_error_handler_should_panic` is a static but was being exported as a function.

For most targets this doesn't matter, but Arm64EC Windows uses different decorations for exported variables vs functions, hence it fails to link when `-Z oom=abort` is enabled.

We've had issues in the past with statics like this (see rust-lang/rust#141061) but the tldr; is that Arm64EC needs symbols correctly exported as either a function or data, and data MUST and MUST ONLY be marked `dllimport` when the symbol is being imported from another binary, which is non-trivial to calculate for these compiler-generated statics.

So, instead, the easiest thing to do is to make `__rust_alloc_error_handler_should_panic` a function instead.

Since `__rust_alloc_error_handler_should_panic` isn't involved in any linking shenanigans, I've marked it as `AlwaysInline` with the hopes that the various backends will see that it is just returning a constant and perform the same optimizations as the previous implementation.

r? `@bjorn3`
2025-07-04 16:22:36 +02:00
Daniel Paoliello
2b22d0f0d2 Make __rust_alloc_error_handler_should_panic a function 2025-07-03 10:52:21 -07:00
Jana Dönszelmann
f6d37a25a9 Rollup merge of #134006 - klensy:typos, r=nnethercote
setup typos check in CI

This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying?

Also includes commits with actual typo fixes.

MCP: https://github.com/rust-lang/compiler-team/issues/817

typos check currently turned for:
* ./compiler
* ./library
* ./src/bootstrap
* ./src/librustdoc

After merging, PRs which enables checks for other crates (tools) can be implemented too.

Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr.

Check typos: `python x.py test tidy --extra-checks=spellcheck`
Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo)

Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.
2025-07-03 13:29:35 +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
наб
a0111ec7a1 awhile -> a while where appropriate 2025-07-02 20:17:29 +02:00
Matthias Krüger
0d5af18c14 Rollup merge of #141847 - xizheyin:141837, r=jhpratt
Explain `TOCTOU` on the top of `std::fs`, and reference it in functions

Fixes rust-lang/rust#141837

r? ``````@workingjubilee``````
2025-07-02 19:28:03 +02:00
bors
f51c9870ba Auto merge of #142974 - cuviper:stage0-bump, r=Mark-Simulacrum
Update stage0 to 1.89.0-beta.1

- Update version placeholders
- Update stage0 to 1.89.0-beta.1
- Update `STAGE0_MISSING_TARGETS`
- Update `cfg(bootstrap)`

r? `@Mark-Simulacrum`

try-job: dist-i586-gnu-i586-i686-musl
2025-07-02 01:41:18 +00:00