Commit graph

18854 commits

Author SHA1 Message Date
Matthias Krüger
efca25fddc
Rollup merge of #139745 - thaliaarchi:iter-unused-clone-copy, r=joboet
Avoid unused clones in `Cloned<I>` and `Copied<I>`

Avoid cloning in `Cloned<I>` or copying in `Copied<I>` when elements are only needed by reference or not at all. There is already some precedent for this, given that `__iterator_get_unchecked` is implemented, which can skip elements. The reduced clones are technically observable by a user impl of `Clone`.

r? libs-api
2025-04-14 21:55:37 +02:00
bors
990039ec53 Auto merge of #139814 - matthiaskrgr:rollup-lxkkcz6, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #139127 (Fix up partial res of segment in primitive resolution hack)
 - #139392 (Detect and provide suggestion for `&raw EXPR`)
 - #139767 (Visit place in `BackwardIncompatibleDropHint` statement)
 - #139777 (Remove `define_debug_via_print` for `ExistentialProjection`, use regular structural debug impl)
 - #139796 (ptr docs: add missing backtics around 'usize')
 - #139801 (Add myself to mailmap)
 - #139804 (use `realpath` in `bootstrap.py` when creating build-dir)
 - #139807 (Improve wording of post-merge report)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-14 16:45:11 +00:00
bors
07d3fd1d9b Auto merge of #138603 - xizheyin:issue-137405, r=chenyukang
Report line number of test when should_panic test failed

Closes #137405

---

try-job: x86_64-gnu-llvm-19-3
try-job: test-various
2025-04-14 13:33:44 +00:00
Ralf Jung
5827183801 ptr docs: add missing backtics around 'usize' 2025-04-14 13:56:51 +02:00
xizheyin
c73598f0fb Report span of test when should_panic test failed
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-04-14 10:36:11 +08:00
Thalia Archibald
ed5f31ab01 Avoid unused clones in Cloned<I> and Copied<I>
Avoid cloning in `Cloned<I>` or copying in `Copied<I>` when elements are
only needed by reference or not at all. There is already some precedent
for this, given that `__iterator_get_unchecked` is implemented, which
can skip elements. The reduced clones are technically observable by a
user impl of `Clone`.
2025-04-13 16:23:12 -07:00
Jacob Pratt
d04df1cba9
Rollup merge of #137043 - Sky9x:unsafe-pinned-pt1-libs, r=tgross35,RalfJung,WaffleLapkin
Initial `UnsafePinned` implementation [Part 1: Libs]

Initial libs changes necessary to unblock further work on [RFC 3467](https://rust-lang.github.io/rfcs/3467-unsafe-pinned.html).
Tracking issue: #125735

This PR is split off from #136964, and includes just the libs changes:
- `UnsafePinned` struct
- private `UnsafeUnpin` structural auto trait
- Lang items for both
- Compiler changes necessary to block niches on `UnsafePinned`

This PR does not change codegen, miri, the existing `!Unpin` hack, or anything else. That work is to be split into later PRs.

---

cc ``@RalfJung`` ``@Noratrieb``

``@rustbot`` label F-unsafe_pinned T-libs-api
2025-04-13 17:37:51 -04:00
bors
092a284ba0 Auto merge of #139746 - ChrisDenton:rollup-eq08b2e, r=ChrisDenton
Rollup of 10 pull requests

Successful merges:

 - #138972 (std: Fix build for NuttX targets)
 - #139177 (Use -C target-cpu=z13 on s390x vector test)
 - #139511 (libtest: Pass the test's panic payload as Option instead of Result)
 - #139605 (update ```miniz_oxide``` to 0.8.8)
 - #139618 (compiletest: Make `SUGGESTION` annotations viral)
 - #139677 (Fix profiler_builtins build script to handle full path to profiler lib)
 - #139683 (Use `with_native_path` for Windows)
 - #139710 (Move `args` into `std::sys`)
 - #139721 (End all lines in src/stage0 with trailing newline)
 - #139726 (Move `select_unpredictable` to the `hint` module)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-13 14:56:44 +00:00
Chris Denton
f1d0b9c645
Rollup merge of #139726 - Amanieu:select_unpredictable_hint, r=dtolnay
Move `select_unpredictable` to the `hint` module

There has been considerable discussion in both the ACP (rust-lang/libs-team#468) and tracking issue (#133962) about whether the `bool::select_unpredictable` method should be in `core::hint` instead.

I believe this is the right move for the following reasons:
- The documentation explicitly says that it is a hint, not a codegen guarantee.
- `bool` doesn't have a corresponding `select` method, and I don't think we should be adding one.
- This shouldn't be something that people reach for with auto-completion unless they specifically understand the interactions with branch prediction. Using conditional moves can easily make code *slower* by preventing the CPU from speculating past the condition due to the data dependency.
- Although currently `core::hint` only contains no-ops, this isn't a hard rule (for example `unreachable_unchecked` is a bit of a gray area). The documentation only status that the module contains "hints to compiler that affects how code should be emitted or optimized". This is consistent with what `select_unpredictable` does.
2025-04-13 11:48:20 +00:00
Chris Denton
daed9e2d9f
Rollup merge of #139710 - thaliaarchi:move-args-pal, r=joboet
Move `args` into `std::sys`

Move platform definitions of `args` into `std::sys`, as part of https://github.com/rust-lang/rust/issues/117276.

cc ``@joboet``
2025-04-13 11:48:19 +00:00
Chris Denton
8a6d6f5ae5
Rollup merge of #139683 - ChrisDenton:windows-with-native, r=tgross35,joboet
Use `with_native_path` for Windows

Ideally, each platform should use their own native path type internally. This will, for example, allow passing a UTF-16 string directly to `std::fs::File::open` and therefore avoid the need for allocating a new null-terminated wide string. However, doing that for every function and platform all at once makes for a large PR that is way too prone to breaking. So this just does some of the Windows parts.

As with the previous Unix PR (#138832) this is intended to be merely a refactoring so I've avoided anything that may require more substantial changes.
2025-04-13 11:48:18 +00:00
Chris Denton
f2a2135dc6
Rollup merge of #139677 - jchecahi:profiler-builtin-rtlib-path-fix, r=kobzol
Fix profiler_builtins build script to handle full path to profiler lib

LLVM_PROFILER_RT_LIB may be set to an absolute path (e.g., in Fedora builds), but `-l` expects a library name, not a path. After #138273, this caused builds to fail with a "could not find native static library" error.

This patch updates the build script to split the path into directory and filename, using `cargo::rustc-link-search` for the directory and `cargo::rustc-link-lib=+verbatim` for the file. This allows profiler_builtins to correctly link the static library even when an absolute path is provided.
2025-04-13 11:48:18 +00:00
Chris Denton
cc9420f3b3
Rollup merge of #139605 - oyvindln:update_miniz_oxide_0_8, r=Mark-Simulacrum
update ```miniz_oxide``` to 0.8.8

I would normally let the auto actions handle this but it turns out 0.8.7 can trigger a panic when debug assertions are enabled in a few cases so I feel it's important it gets sorted more quickly. (and I would ideally like to yank that version but was worried that could cause some issues had been pulled in as a dependency by this repo already before I discovered the problem)

As it can only happen when debug assertions are enabled (the overflow results in the intended result so it doesn't cause any issue in release mode) and using the wrapping buffer mode when decompressing it is very unlikely to cause any issues here but I would like to get it sorted just to be safe. ```miniz_oxide``` is used in the standard library (and some tools) via ```backtrace-rs ``` which doesn't use a wrapping buffer, and thus won't trigger this condition. There does however seem like there are some tools that do dependency on ```flate2``` which does use ```miniz_oxide``` decompression using a a wrapping buffer and could in theory trigger it if they are run when compiled with debug assertions enabled.

It's kinda unclear what version what tool uses though as several of them specify older versions of flate2 which depended on ```miniz_oxide``` 0.7.x in cargo.toml, and ```miniz_oxide```, and not all have a cargo.lock and due to an older version of ```backtrace``` being in the root Cargo.lock which still depended on ```miniz_oxide``` 0.7.4, so that version is also pulled in alongside the newer version.
2025-04-13 11:48:17 +00:00
Chris Denton
bde65bd926
Rollup merge of #139511 - Zalathar:panic-payload, r=Mark-Simulacrum
libtest: Pass the test's panic payload as Option instead of Result

Passing a `Result<(), &dyn Any>` to `calc_result` requires awkward code at both call sites to build a fake result, for no real benefit. It's much easier to just pass the payload as `Option<&dyn Any>`.

No functional change.
2025-04-13 11:48:16 +00:00
Chris Denton
9d2d6a040f
Rollup merge of #138972 - thaliaarchi:nuttx-build, r=Mark-Simulacrum
std: Fix build for NuttX targets

Fix std build for all NuttX targets. It is the single largest set of failures on <https://does-it-build.noratrieb.dev/>. Although, ESP-IDF also requires these same gates, there are other issues for those targets.

This can verified be running `x check library/std --target=` for all NuttX targets.

cc ``@no1wudi``
2025-04-13 11:48:15 +00:00
bors
53d4476111 Auto merge of #138881 - scottmcm:more-chaining-ord, r=Mark-Simulacrum
Use the chaining methods on PartialOrd for slices too

#138135 added these doc-hidden trait methods to improve the tuple codegen.  This PR adds more implementations and callers so that the codegen for slice (and array) comparisons also improves.
2025-04-13 11:47:23 +00:00
bors
65fa0ab924 Auto merge of #139734 - ChrisDenton:rollup-28qn740, r=ChrisDenton
Rollup of 6 pull requests

Successful merges:

 - #139107 (std: make `cmath` functions safe)
 - #139607 (Add regression test for #127424)
 - #139691 (Document that `opt-dist` requires metrics to be enabled)
 - #139707 (Fix comment in bootstrap)
 - #139708 (Fix name of field in doc comment)
 - #139709 (bootstrap: fix typo in doc string)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-13 07:10:43 +00:00
Sky
21b7360a9a
Initial UnsafePinned/UnsafeUnpin impl [Part 1: Libs] 2025-04-13 01:11:04 -04:00
Scott McMurray
756670f40e Extend the chaining logic to slices too 2025-04-12 22:10:17 -07:00
Chris Denton
5b2fd54829
Rollup merge of #139107 - joboet:safe_cmath, r=ibraheemdev
std: make `cmath` functions safe

The floating point intrinsics are more difficult, I'll probably wait until #119899 has merged before making them safe as well.
2025-04-13 03:07:06 +00:00
Amanieu d'Antras
5d90ccb0fa Move select_unpredictable to the hint module 2025-04-13 01:34:25 +01:00
Chris Denton
739bf9b753
Rollup merge of #139713 - GenYuLi:master, r=compiler-errors
Fix typo in documentation

Correct the misspelling of "indentifier" to "identifier" in `library/alloc/src/fmt.rs`.
2025-04-12 21:05:31 +00:00
Chris Denton
824ef7fd64
Rollup merge of #139701 - Rudxain:doc-pow2, r=tgross35
docs: clarify uint exponent for `is_power_of_two`

This makes the documentation more explicit for that method. I know this might seem "nit-picky", but `k` could be interpreted as "any Real or Complex number". A trivial example would be $`3 = 2^{log_2(3)}`$ which "proves that three is a power of two" (according to that vague definition).

BTW, when I read the implementation, I was surprised to see that `1` is considered a power of 2 despite being odd (it does make sense in some contexts, but still not intuitive). So I wrote "positive int" before correcting it to "unsigned int"
2025-04-12 21:05:30 +00:00
Chris Denton
e0f92bb53c
Rollup merge of #139688 - rust-lang:notriddle/io-result-unbox, r=GuillaumeGomez
rustdoc-search: add unbox flag to Result aliases

Fixes #139665
2025-04-12 21:05:30 +00:00
Chris Denton
096369d97f
Rollup merge of #139382 - ChrisDenton:windows-bindgen-0-61, r=Mark-Simulacrum
Update windows-bindgen to 0.61.0

This updates the automatically generate Windows API bindings. Not much changed this time:

- There's now `Default` implementations for many types, which is convenient. It does however conflict with one place where we implemented a non-zeroed default (to set the length field). But that's no big problem.
- The `--no-core` flag has been renamed to `--no-deps` to more accurately reflect its meaning (i.e. generate all necessary code without requiring additional dependencies).
- The `--link` flag allows us to set the location of the `link!` macro. Currently we use our workspace's `windows_targets` crate but we could move it into library/std using `--link`. However, this would need to be co-ordinated with the `backtrace` crate (which is a separate crate but included in std using `#[path]`). So I've left that for another time.
2025-04-12 21:05:29 +00:00
Chris Denton
0ea345a3c3
Rollup merge of #139276 - tgross35:enable-f16-without-neon, r=Mark-Simulacrum
Revert "Disable `f16` on Aarch64 without `neon`"

The LLVM issue [1] was resolved and the fix was synced to rust-lang/rust in [2].

This reverts commit c51b229140.

[1]: https://github.com/llvm/llvm-project/issues/129394
[2]: https://github.com/rust-lang/rust/pull/138695

try-job: aarch64-gnu
try-job: aarch64-gnu-debug
try-job: armhf-gnu
try-job: dist-various-1
2025-04-12 21:05:28 +00:00
Chris Denton
2722e82653
Rollup merge of #139163 - scottmcm:stabilize-exact_div, r=RalfJung
indirect-const-stabilize the `exact_div` intrinsic

See https://github.com/rust-lang/rust/issues/74985#issuecomment-2759179184
2025-04-12 21:05:27 +00:00
GenYuLi
1baa62e884 Fix typo in documentation
Correct the misspelling of "indentifier" to "identifier" in `library/alloc/src/fmt.rs`.
2025-04-12 22:26:38 +08:00
Thalia Archibald
bea202253e Unify owned Args types between platforms 2025-04-12 05:11:27 -07:00
Thalia Archibald
e014fd6b87 Use unsupported args for espidf and vita 2025-04-12 04:38:20 -07:00
Thalia Archibald
6ffebb65d6 Move args into std::sys 2025-04-12 03:10:21 -07:00
Ricardo Fernández Serrata
072678ec86
docs: clarify uint exponent for is_power_of_two 2025-04-12 02:18:40 -04:00
bors
1bc56185ee Auto merge of #139430 - scottmcm:polymorphic-array-into-iter, r=cuviper
Some checks failed
Post merge analysis / analysis (push) Has been cancelled
Polymorphize `array::IntoIter`'s iterator impl

Today we emit all the iterator methods for every different array width.  That's wasteful since the actual array length never even comes into it -- the indices used are from the separate `alive: IndexRange` field, not even the `N` const param.

This PR switches things so that an `array::IntoIter<T, N>` stores a `PolymorphicIter<[MaybeUninit<T>; N]>`, which we *unsize* to `PolymorphicIter<[MaybeUninit<T>]>` and call methods on that non-`Sized` type for all the iterator methods.

That also necessarily makes the layout consistent between the different lengths of arrays, because of the unsizing.  Compare that to today <https://rust.godbolt.org/z/Prb4xMPrb>, where different widths can't even be deduped because the offset to the indices is different for different array widths.
2025-04-11 23:21:31 +00:00
Jacob Pratt
a6608294a9
Rollup merge of #137835 - scottmcm:signum, r=compiler-errors
Use `BinOp::Cmp` for `iNN::signum`

This way it can use the nice new LLVM intrinsic in LLVM20.
2025-04-11 21:20:59 +02:00
Michael Howell
e013cf8afc rustdoc-search: add unbox flag to Result aliases
Fixes #139665
2025-04-11 11:36:40 -07:00
Chris Denton
b613e9781a
Use with_native_path for Windows
Also add a WCStr type
2025-04-11 18:02:03 +00:00
Jesus Checa Hidalgo
dc0fbcab7e Fix profiler_builtins build script to handle full path to profiler lib
LLVM_PROFILER_RT_LIB may be set to an absolute path (e.g., in Fedora builds),
but `-l` expects a library name, not a path. After #138273, this caused builds
to fail with a "could not find native static library" error.

This patch updates the build script to split the path into directory and
filename, using `cargo::rustc-link-search` for the directory and
`cargo::rustc-link-lib=+verbatim` for the file. This allows profiler_builtins to
correctly link the static library even when an absolute path is provided.
2025-04-11 16:57:38 +02:00
Stuart Cook
c8acc23d1d
Rollup merge of #139600 - tgross35:update-builtins, r=tgross35
Update `compiler-builtins` to 0.1.153

Includes the following changes:

* Avoid OOB access in `memcpy` and `memmove` [1]
* Enable intrinsics on AVR [2]
* `libm` updates to avoid using `core::arch` vector intrinsics [3]
* Re-enable `f16` on aarch64 without Neon [4]

[1]: https://github.com/rust-lang/compiler-builtins/pull/799
[2]: https://github.com/rust-lang/compiler-builtins/pull/791
[3]: https://github.com/rust-lang/compiler-builtins/pull/814
[4]: https://github.com/rust-lang/compiler-builtins/pull/809
2025-04-11 13:31:49 +10:00
Stuart Cook
a7d7a6d0eb
Rollup merge of #139447 - izarma:issue-108131-fix, r=scottmcm
doc changes: debug assertions -> overflow checks

This PR is for the following issue:
https://github.com/rust-lang/rust/issues/108131

has some changes in docs
2025-04-11 13:31:46 +10:00
Stuart Cook
45ebc4060b
Rollup merge of #137447 - folkertdev:simd-extract-insert-dyn, r=scottmcm
add `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`

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

adds `core::intrinsics::simd::{simd_extract_dyn, simd_insert_dyn}`, which contrary to their non-dyn counterparts allow a non-const index. Many platforms (but notably not x86_64 or aarch64) have dedicated instructions for this operation, which stdarch can emit with this change.

Future work is to also make the `Index` operation on the `Simd` type emit this operation, but the intrinsic can't be used directly. We'll need some MIR shenanigans for that.

r? `@ghost`
2025-04-11 13:31:43 +10:00
Scott McMurray
56c08d9b32 indirect-const-stabilize the exact_div intrinsic 2025-04-10 20:03:06 -07:00
bors
0fe8f3454d Auto merge of #137412 - scottmcm:redo-swap, r=cuviper
Ensure `swap_nonoverlapping` is really always untyped

This replaces #134954, which was arguably overcomplicated.

## Fixes #134713

Actually using the type passed to `ptr::swap_nonoverlapping` for anything other than its size + align turns out to not work, so this goes back to always erasing the types down to just bytes.

(Except in `const`, which keeps doing the same thing as before to preserve `@RalfJung's` fix from #134689)

## Fixes #134946

I'd previously moved the swapping to use auto-vectorization *on bytes*, but someone pointed out on Discord that the tail loop handling from that left a whole bunch of byte-by-byte swapping around.  This goes back to manual tail handling to avoid that, then still triggers auto-vectorization on pointer-width values.  (So you'll see `<4 x i64>` on `x86-64-v3` for example.)
2025-04-10 20:19:11 +00:00
Folkert de Vries
59c55339af
add simd_insert_dyn and simd_extract_dyn 2025-04-10 21:22:07 +02:00
Trevor Gross
b435def33c Update compiler-builtins to 0.1.153
Includes the following changes:

* Avoid OOB access in `memcpy` and `memmove` [1]
* Enable intrinsics on AVR [2]
* `libm` updates to avoid using `core::arch` vector intrinsics [3]
* Re-enable `f16` on aarch64 without Neon [4]

[1]: https://github.com/rust-lang/compiler-builtins/pull/799
[2]: https://github.com/rust-lang/compiler-builtins/pull/791
[3]: https://github.com/rust-lang/compiler-builtins/pull/814
[4]: https://github.com/rust-lang/compiler-builtins/pull/809
2025-04-10 17:40:15 +00:00
Scott McMurray
4207c786e7 PR feedback 2025-04-09 21:44:59 -07:00
bors
6813f955a6 Auto merge of #139279 - BoxyUwU:bump-boostrap, r=jieyouxu
Bump boostrap compiler to new beta

try-job: `*msvc*`
2025-04-10 00:43:25 +00:00
oyvindln
77116881a8 update miniz_oxide to 0.8.8
0.8.7 can trigger a panic when debug assertions are enabled when used via flate2 in some cases
2025-04-10 00:30:53 +02:00
bors
51548ce71f Auto merge of #139595 - matthiaskrgr:rollup-kaa8aim, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #138470 (Test interaction between RFC 2229 migration and use closures)
 - #138628 (Add more ergonomic clone tests)
 - #139164 (std: improve documentation for get_mut() methods regarding forgotten guards)
 - #139488 (Add missing regression GUI test)
 - #139489 (compiletest: Add directive `dont-require-annotations`)
 - #139513 (Report higher-ranked trait error when higher-ranked projection goal fails in new solver)
 - #139521 (triagebot: roll compiler reviewers for rustc/unstable book)
 - #139532 (Update `u8`-to-and-from-`i8` suggestions.)
 - #139551 (report call site of inlined scopes for large assignment lints)
 - #139575 (Remove redundant words)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-09 21:35:22 +00:00
Matthias Krüger
7aab307541
Rollup merge of #139575 - timesince:master, r=wesleywiser
Remove redundant words

Remove redundant words
2025-04-09 20:23:13 +02:00
Matthias Krüger
a8b0d56f6f
Rollup merge of #139532 - bjoernager:master, r=tgross35
Update `u8`-to-and-from-`i8` suggestions.

`u8::cast_signed` and `i8::cast_unsigned` have been stabilised, but `i8::from_ne_bytes` et al. still suggest using `as i8` or `as u8`.
2025-04-09 20:23:12 +02:00