Commit graph

18660 commits

Author SHA1 Message Date
Christopher Durham
2e5a76cd1e Use cfg_match in core 2025-03-26 14:32:35 -04:00
Thalia Archibald
a475f5d181 Fix typo in error message 2025-03-25 23:37:22 -07:00
bors
6e8abb5ec6 Auto merge of #138956 - jhpratt:rollup-6g7ppwd, r=jhpratt
Rollup of 11 pull requests

Successful merges:

 - #138128 (Stabilize `#![feature(precise_capturing_in_traits)]`)
 - #138834 (Group test diffs by stage in post-merge analysis)
 - #138867 (linker: Fix staticlib naming for UEFI)
 - #138874 (Batch mark waiters as unblocked when resuming in the deadlock handler)
 - #138875 (Trusty: Fix build for anonymous pipes and std::sys::process)
 - #138877 (Ignore doctests only in specified targets)
 - #138885 (Fix ui pattern_types test for big-endian platforms)
 - #138905 (Add target maintainer information for powerpc64-unknown-linux-musl)
 - #138911 (Allow defining opaques in statics and consts)
 - #138917 (rustdoc: remove useless `Symbol::is_empty` checks.)
 - #138945 (Override PartialOrd methods for bool)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-26 03:21:26 +00:00
Jacob Pratt
deb987b69d
Rollup merge of #138945 - DaniPopes:override-partialord-bool, r=scottmcm
Override PartialOrd methods for bool

I noticed that `PartialOrd` implementation for `bool` does not override the individual operator methods, unlike the other primitive types like `char` and integers.

This commit extracts these `PartialOrd` overrides shared by the other primitive types into a macro and calls it on `bool` too.

CC `@scottmcm` for our recent adventures in `PartialOrd` land
2025-03-25 20:34:50 -04:00
Jacob Pratt
0d61b83f59
Rollup merge of #138875 - thaliaarchi:trusty-build, r=randomPoison,saethlin
Trusty: Fix build for anonymous pipes and std::sys::process

PRs #136842 (Add libstd support for Trusty targets), #137793 (Stablize anonymous pipe), and #136929 (std: move process implementations to `sys`) merged around the same time, so update Trusty to take them into account.

cc `@randomPoison`
2025-03-25 20:34:47 -04:00
bors
068609ce76 Auto merge of #138601 - RalfJung:wasm-abi-fcw, r=alexcrichton
add FCW to warn about wasm ABI transition

See https://github.com/rust-lang/rust/issues/122532 for context: the "C" ABI on wasm32-unk-unk will change. The goal of this lint is to warn about any function definition and calls whose behavior will be affected by the change. My understanding is the following:
- scalar arguments are fine
  - including 128 bit types, they get passed as two `i64` arguments in both ABIs
- `repr(C)` structs (recursively) wrapping a single scalar argument are fine (unless they have extra padding due to over-alignment attributes)
- all return values are fine

`@bjorn3` `@alexcrichton` `@Manishearth` is that correct?

I am making this a "show up in future compat reports" lint to maximize the chances people become aware of this. OTOH this likely means warnings for most users of Diplomat so maybe we shouldn't do this?

IIUC, wasm-bindgen should be unaffected by this lint as they only pass scalar types as arguments.

Tracking issue: https://github.com/rust-lang/rust/issues/138762
Transition plan blog post: https://github.com/rust-lang/blog.rust-lang.org/pull/1531

try-job: dist-various-2
2025-03-26 00:06:46 +00:00
DaniPopes
154cb083e7
Override PartialOrd methods for bool
I noticed that `PartialOrd` implementation for `bool` does not override the
individual operator methods, unlike the other primitive types like `char`
and integers.

This commit extracts these `PartialOrd` overrides shared by the other
primitive types into a macro and calls it on `bool` too.
2025-03-25 21:02:55 +01:00
Matthias Krüger
5f6c1a9f57
Rollup merge of #135745 - bardiharborow:std/net/rfc9602, r=cuviper
Recognise new IPv6 non-global range from IETF RFC 9602

This PR adds the `5f00::/16` range defined by [IETF RFC 9602](https://datatracker.ietf.org/doc/rfc9602/) to those ranges which `Ipv6Addr::is_global` recognises as a non-global IP. This range is used for Segment Routing (SRv6) SIDs.

See also: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml
Unstable tracking issue: #27709
2025-03-25 18:09:03 +01:00
Ralf Jung
61e24e630d allow wasm_c_abi in proc_macro bridge 2025-03-25 08:22:35 +01:00
Matthias Krüger
0c25157784
Rollup merge of #138800 - RalfJung:const_box, r=oli-obk
remove remnants of const_box feature

This feature requires major design work, and the few methods it gates currently aren't actually useful. Let's reset to a clean slate so when a design materializes, we can start from scratch.

Closes https://github.com/rust-lang/rust/issues/92521 by removing the feature it tracks.

r? ````@oli-obk````
2025-03-24 20:40:07 +01:00
Matthias Krüger
b157594165
Rollup merge of #138662 - Ayush1325:uefi-fs-1, r=nicholasbishop,petrochenkov
Implement some basics in UEFI fs

- Just getting some basics out of the way while waiting for #138236 to be merged.
- Adds `fs::canonicalize`. Should be same as absolute in case of UEFI since there is no symlink support and absolute path is guaranteed to be uniqe according to spec.
- Make `fs::lstat` same as `fs::stat`. Should be same since UEFI does not have symlink support.
- Implement `OptionOptions`.

cc ````@nicholasbishop```` ````@dvdhrm````
2025-03-24 20:40:06 +01:00
Ayush Singh
021d23b64e
std: fs: uefi: Implement OpenOptions
UEFI does not have specific modes for create_new, truncate and append.
So those need to to be simulated after opening the file.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-24 08:44:31 +05:30
Ayush Singh
fc0cf52e28
std: fs: uefi: Make lstat call stat
- UEFI does not have symlinks. So lstat and stat should behave the same.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-24 08:40:08 +05:30
Ayush Singh
0cd1d516ae
std: fs: uefi: Implement canonicalize
- Should be same as absolute in UEFI since there are no symlinks.
- Also each absolute path representation should be unique according to
  the UEFI specification.

Signed-off-by: Ayush Singh <ayush@beagleboard.org>
2025-03-24 08:40:07 +05:30
Thalia Archibald
b672659472 Trusty: Fix build for anonymous pipes and std::sys::process
PRs #136842 (Add libstd support for Trusty targets), #137793 (Stablize
anonymous pipe), and #136929 (std: move process implementations to
`sys`) merged around the same time, so update Trusty to take them into
account.
2025-03-23 19:32:20 -07:00
Jacob Pratt
b406d9aaaa
Rollup merge of #138728 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.152

Includes the following changes related to unordered atomics:

* Remove element_unordered_atomic intrinsics [1]
* Remove use of `atomic_load_unordered` and undefined behaviour [2]

There are a handful of other small changes, but nothing else user-visible.

[1]: https://github.com/rust-lang/compiler-builtins/pull/789
[2]: https://github.com/rust-lang/compiler-builtins/pull/790
2025-03-23 20:44:12 -04:00
Jacob Pratt
8e30df7f26
Rollup merge of #138671 - ChrisDenton:filetype, r=joshtriplett
Fix `FileType` `PartialEq` implementation on Windows

Fixes #138668

On Windows the [`FileType`](https://doc.rust-lang.org/stable/std/fs/struct.FileType.html) struct was deriving `PartialEq` which in turn means it was doing a bit-for-bit comparison on the file attributes and reparse point. This is wrong because `attributes` may contain many things unrelated to file type.

`FileType` on Windows allows for four possible combinations (see also [`FileTypeExt`](https://doc.rust-lang.org/stable/std/os/windows/fs/trait.FileTypeExt.html)): `file`, `dir`, `symlink_file` and `symlink_dir`. So the new implementation makes sure both symlink and directory information match (and only those things).

This could be considered just a bug fix but it is a behaviour change so someone from libs-api might want to FCP this (or might not)...
2025-03-23 20:44:11 -04:00
Jacob Pratt
1ba9b7873a
Rollup merge of #138135 - scottmcm:chaining-ord, r=Mark-Simulacrum
Simplify `PartialOrd` on tuples containing primitives

We noticed in https://github.com/rust-lang/rust/pull/133984#issuecomment-2704011800 that currently the tuple comparison code, while it [does optimize down](https://github.com/rust-lang/rust/blob/master/tests/codegen/comparison-operators-2-tuple.rs) today, is kinda huge: <https://rust.godbolt.org/z/xqMoeYbhE>

This PR changes the tuple code to go through an overridable "chaining" version of the comparison functions, so that for simple things like `(i16, u16)` and `(f32, f32)` (as seen in the new MIR pre-codegen test) we just directly get the
```rust
if lhs.0 == rhs.0 { lhs.0 OP rhs.0 }
else { lhs.1 OP rhs.1 }
```
version in MIR, rather than emitting a mess for LLVM to have to clean up.

Test added in the first commit, so you can see the MIR diff in the second one.
2025-03-23 20:44:09 -04:00
Trevor Gross
95181ae170 Update compiler-builtins to 0.1.152
Includes the following changes related to unordered atomics:

* Remove element_unordered_atomic intrinsics [1]
* Remove use of `atomic_load_unordered` and undefined behaviour [2]

There are a handful of other small changes, but nothing else
user-visible.

[1]: https://github.com/rust-lang/compiler-builtins/pull/789
[2]: https://github.com/rust-lang/compiler-builtins/pull/790
2025-03-24 00:29:21 +00:00
Scott McMurray
7781346243 Stop using specialization for this
Uses `__`-named `doc(hidden)` methods instead.
2025-03-23 15:27:31 -07:00
Michael Goulet
1e023420f9
Rollup merge of #138854 - TaKO8Ki:invalid-extern-fn-body, r=compiler-errors
Fix ICE #138415 for invalid extern function body

Fixes #138415
2025-03-23 14:59:35 -04:00
Michael Goulet
f4096dcda8
Rollup merge of #138667 - Ayush1325:uefi-mkdir, r=joboet
std: uefi: fs: Implement mkdir

- Since there is no direct mkdir in UEFI, first check if a file/dir with same path exists and then create the directory.

cc `@dvdhrm` `@nicholasbishop`
2025-03-23 14:59:33 -04:00
Michael Goulet
bb49f0d8b6
Rollup merge of #138631 - thaliaarchi:sgx-read-buf-test, r=workingjubilee
Update test for SGX now implementing `read_buf`

In #108326, `read_buf` was implemented for a variety of types, but SGX was saved for later. Update a test from then, now that #137355 implemented it for SGX types.

cc ````@jethrogb````
2025-03-23 14:59:32 -04:00
Michael Goulet
d7c5f5f319
Rollup merge of #138236 - Ayush1325:uefi-event, r=petrochenkov
uefi: Add OwnedEvent abstraction

- Events are going to become quite important for Networking, so needed owned abstractions.
- Switch to OwnedEvent abstraction for Exit boot services event.

cc ````@nicholasbishop````
2025-03-23 14:59:30 -04:00
Michael Goulet
145fe2d648
Rollup merge of #136040 - mu001999-contrib:cleanup, r=Mark-Simulacrum
Remove unused trait BoundedSize

Detected by #128637

The usage of this trait is removed in #135104

r? `@the8472`
2025-03-23 14:59:29 -04:00
bors
aa8f0fd716 Auto merge of #136929 - joboet:move_process_pal, r=Mark-Simulacrum
std: move process implementations to `sys`

As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-23 14:10:35 +00:00
Takayuki Maeda
34b7d51b95 fix typo 2025-03-23 17:47:10 +09:00
bors
60a3084f64 Auto merge of #136769 - thaliaarchi:io-optional-methods/stdio, r=joboet
Provide optional `Read`/`Write` methods for stdio

Override more of the default methods for `io::Read` and `io::Write` for stdio types, when efficient to do so, and deduplicate unsupported types.

Tracked in https://github.com/rust-lang/rust/issues/136756.

try-job: x86_64-msvc-1
2025-03-23 06:23:51 +00:00
bors
f08d5c01e6 Auto merge of #138833 - joboet:optimize-repeat-n, r=thomcc
core: optimize `RepeatN`

...by adding an optimized implementation of `try_fold` and `fold` as well as replacing some unnecessary `mem::replace` calls with `MaybeUninit` helper methods.
2025-03-23 03:11:13 +00:00
bors
756bff97ea Auto merge of #138841 - matthiaskrgr:rollup-bfkls57, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #138018 (rustdoc: Use own logic to print `#[repr(..)]` attributes in JSON output.)
 - #138294 (Mark some std tests as requiring `panic = "unwind"`)
 - #138468 (rustdoc js: add nonnull helper and typecheck src-script.js)
 - #138675 (Add release notes for 1.85.1)
 - #138765 (Fix Thread::set_name on cygwin)
 - #138786 (Move some driver code around)
 - #138793 (target spec check: better error when llvm-floatabi is missing)
 - #138822 (De-Stabilize `file_lock`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-22 23:59:01 +00:00
bors
b48576b4db Auto merge of #138831 - matthiaskrgr:rollup-3t0dqiz, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138609 (Add stack overflow handler for cygwin)
 - #138639 (Clean UI tests 2 of n)
 - #138773 (catch_unwind intrinsic: document return value)
 - #138782 (test(ui): add tuple-struct-where-clause-suggestion ui test for #91520)
 - #138794 (expand: Do not report `cfg_attr` traces on macros as unused attributes)
 - #138801 (triagebot: add autolabel rules for D-* and L-*)
 - #138804 (Allow inlining for `Atomic*::from_ptr`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-22 20:52:30 +00:00
Matthias Krüger
3f59916a30
Rollup merge of #138822 - moxian:unlock, r=joshtriplett
De-Stabilize `file_lock`

This reverts #136794

FCP on the tracking issue (#130994) passsed successfully https://github.com/rust-lang/rust/issues/130994#issuecomment-2646158607 but there are now concerns about the suitability of the proposed API (https://github.com/rust-lang/rust/issues/130994#issuecomment-2734608366)

On zullip it was [suggested](506823067) that it would be better to temporarily(?) destabilize the feature ASAP to buy us some more time reflecting on the API.

This PR implements the revert.

The feature is not currently on beta (https://github.com/rust-lang/rust/blob/beta/library/std/src/fs.rs#L672) so a beta backport is not yet neccessary.

If this revert is accepted, the tracking issue (#130994) should be reopened
2025-03-22 21:34:40 +01:00
Matthias Krüger
9a9859637a
Rollup merge of #138765 - Berrysoft:cygwin-thread-name, r=joboet
Fix Thread::set_name on cygwin

Just like Linux, Cygwin also sets a limitation to thread name.

8e50c7af7c/winsup/cygwin/thread.cc (L3175)
2025-03-22 21:34:38 +01:00
Matthias Krüger
53076de369
Rollup merge of #138294 - paulmenage:test-panic-unwind, r=bjorn3
Mark some std tests as requiring `panic = "unwind"`

This allows these test modules to pass on builds/targets without unwinding support, where `panic = "abort"` - the ignored tests are for functionality that's not supported on those targets.
2025-03-22 21:34:36 +01:00
bors
d93f678fa5 Auto merge of #138830 - matthiaskrgr:rollup-gaxgfwl, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #138410 (Couple mir building cleanups)
 - #138490 (Forward `stream_position` in `Arc<File>` as well)
 - #138535 (Cleanup `LangString::parse`)
 - #138536 (stable_mir: Add `MutMirVisitor`)
 - #138673 (Fix build failure on Trusty)
 - #138750 (Make `crate_hash` not iterate over `hir_crate` owners anymore)
 - #138763 (jsondocck: Replace `jsonpath_lib` with `jsonpath-rust`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-03-22 14:03:50 +00:00
joboet
51d51c8666
core: optimize RepeatN
...by adding an optimized implementation of `try_fold` and `fold` as well as replacing some unnecessary `mem::replace` calls with `MaybeUninit` helper methods.
2025-03-22 13:35:46 +01:00
joboet
89f85cbfa7
std: move process implementations to sys
As per #117276, this moves the implementations of `Process` and friends out of the `pal` module and into the `sys` module, removing quite a lot of error-prone `#[path]` imports in the process (hah, get it ;-)). I've also made the `zircon` module a dedicated submodule of `pal::unix`, hopefully we can move some other definitions there as well (they are currently quite a lot of duplications in `sys`). Also, the `ensure_no_nuls` function on Windows now lives in `sys::pal::windows` – it's not specific to processes and shared by the argument implementation.
2025-03-22 12:42:34 +01:00
Matthias Krüger
2644500bff
Rollup merge of #138804 - tgross35:atomic-from-ptr-inline, r=RalfJung
Allow inlining for `Atomic*::from_ptr`

Currently this cannot be inlined, which among other things means it can't be used in `compiler-builtins` [1]. These are trivial functions that should be inlineable, so add `#[inline]`.

[1]: https://github.com/rust-lang/compiler-builtins/pull/790#issuecomment-2744371738
2025-03-22 12:00:51 +01:00
Matthias Krüger
ca86dd5036
Rollup merge of #138773 - RalfJung:catch_unwind_docs, r=jhpratt
catch_unwind intrinsic: document return value

Seems like we forgot to document this. The comment reflects what Miri does, which seems to also match what codegen does at least [in `codegen_gnu_try`](b754ef727c/compiler/rustc_codegen_llvm/src/intrinsic.rs (L953-L964)).
2025-03-22 12:00:49 +01:00
Matthias Krüger
92caac41ff
Rollup merge of #138609 - Berrysoft:cygwin-stackoverflow, r=joboet
Add stack overflow handler for cygwin

The cygwin runtime handles stack overflow exception and converts it to `SIGSEGV`, but the passed `si_addr` is obtained from `ExceptionInformation[1]` which is actually an undocumented value when stack overflows. Thus I choose to use Windows API directly to register handler, just like how std does on native Windows. The code is basically copied from the Windows one.

Ref:
* 5ec497dc80/winsup/cygwin/exceptions.cc (L822-L823)
* https://learn.microsoft.com/zh-cn/windows/win32/api/winnt/ns-winnt-exception_record
2025-03-22 12:00:48 +01:00
Matthias Krüger
14f6216cf4
Rollup merge of #138673 - taiki-e:trusty-fix, r=Noratrieb
Fix build failure on Trusty

This target is currently broken due to update to 2024 editon.

```console
$ cargo new --lib repro
$ cd repro
$ cargo check -Z build-std=std --target aarch64-unknown-trusty
   Compiling std v0.0.0 ($HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std)
error: extern blocks must be unsafe
 --> $HOME/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/sys/random/trusty.rs:1:1
  |
1 | / extern "C" {
2 | |     fn trusty_rng_secure_rand(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t);
3 | | }
  | |_^

error: could not compile `std` (lib) due to 1 previous error
```

cc ```@randomPoison``` ```@ahomescu``` ([target maintainers](https://doc.rust-lang.org/nightly/rustc/platform-support/trusty.html#target-maintainers))
2025-03-22 11:59:18 +01:00
Matthias Krüger
07c503c3e4
Rollup merge of #138490 - tbu-:pr_arc_file_pos, r=Noratrieb
Forward `stream_position` in `Arc<File>` as well

It was missed in #137165.
2025-03-22 11:59:16 +01:00
bors
0ce1369bde Auto merge of #136974 - m-ou-se:fmt-options-64-bit, r=scottmcm
Reduce FormattingOptions to 64 bits

This is part of https://github.com/rust-lang/rust/issues/99012

This reduces FormattingOptions from 6-7 machine words (384 bits on 64-bit platforms, 224 bits on 32-bit platforms) to just 64 bits (a single register on 64-bit platforms).

Before:

```rust
pub struct FormattingOptions {
    flags: u32, // only 6 bits used
    fill: char,
    align: Option<Alignment>,
    width: Option<usize>,
    precision: Option<usize>,
}
```

After:

```rust
pub struct FormattingOptions {
    /// Bits:
    ///  - 0-20: fill character (21 bits, a full `char`)
    ///  - 21: `+` flag
    ///  - 22: `-` flag
    ///  - 23: `#` flag
    ///  - 24: `0` flag
    ///  - 25: `x?` flag
    ///  - 26: `X?` flag
    ///  - 27: Width flag (if set, the width field below is used)
    ///  - 28: Precision flag (if set, the precision field below is used)
    ///  - 29-30: Alignment (0: Left, 1: Right, 2: Center, 3: Unknown)
    ///  - 31: Always set to 1
    flags: u32,
    /// Width if width flag above is set. Otherwise, always 0.
    width: u16,
    /// Precision if precision flag above is set. Otherwise, always 0.
    precision: u16,
}
```
2025-03-22 10:56:14 +00:00
Thalia Archibald
f6e90d804a Use unit structs for stateless stdio
This seems to be the pattern for newer pal stdio types.
2025-03-22 01:21:23 -07:00
Thalia Archibald
ec4beda5d2 Implement exact reads for StdinRaw 2025-03-22 01:21:23 -07:00
Thalia Archibald
bd49a4beb7 Implement optional methods for unsupported stdio
Match what `std::io::Empty` does, since it is very similar. However,
still evaluate the `fmt::Arguments` in `write_fmt` to be consistent with
other platforms.
2025-03-22 01:21:23 -07:00
moxian
110f1fe17f Revert "Stabilize file_lock"
This reverts commit 82af73dd4c.
2025-03-21 20:24:31 -07:00
Trevor Gross
eb2a2f86bb Allow inlining for Atomic*::from_ptr
Currently this cannot be inlined, which among other things means it
can't be used in `compiler-builtins` [1]. These are trivial functions
that should be inlineable, so add `#[inline]`.

[1]: https://github.com/rust-lang/compiler-builtins/pull/790#issuecomment-2744371738
2025-03-21 20:51:06 +00:00
Ralf Jung
7b9d5b8758 remove remnants of const_box feature 2025-03-21 21:02:06 +01:00
Mara Bos
d7685f0d0b Add test for Formatter flags. 2025-03-21 17:05:56 +01:00