Commit graph

286430 commits

Author SHA1 Message Date
bors
15f58c46da Auto merge of #139766 - jhpratt:rollup-afrfmnk, r=jhpratt
Rollup of 10 pull requests

Successful merges:

 - #137043 (Initial `UnsafePinned` implementation [Part 1: Libs])
 - #138962 (Expect an array when expected and acutal types are both arrays during cast)
 - #139001 (add `naked_functions_rustic_abi` feature gate)
 - #139379 (Use delayed bug for normalization errors in drop elaboration)
 - #139582 (Various coercion cleanups)
 - #139628 (Suggest remove redundant `$()?` around `vis`)
 - #139644 (Micro-optimize `InstSimplify`'s `simplify_primitive_clone`)
 - #139674 (In `rustc_mir_transform`, iterate over index newtypes instead of ints)
 - #139740 (Convert `tests/ui/lint/dead-code/self-assign.rs` to a known-bug test)
 - #139741 (fix smir's run! doc and import)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-14 00:47:02 +00:00
mejrs
3efd9f5d0c Switch to diagnostic::on_unimplemented 2025-04-14 01:38:18 +02: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
Michael Goulet
2f96e784e2 Visit place in BackwardIncompatibleDropHint statement 2025-04-13 22:01:54 +00:00
Jacob Pratt
7ce62af35a
Rollup merge of #139741 - os-checker:smir-run-macro, r=scottmcm
fix smir's run! doc and import

This PR
* adds missing `extern crate rustc_middle` in `rustc_smir::run!` docstring
* adds missing `use rustc_smir::rustc_internal` in `run_driver!` scope
  * also adjust some tests that don't need to import rustc_internalany more
2025-04-13 17:37:56 -04:00
Jacob Pratt
7ba09db7f2
Rollup merge of #139740 - jieyouxu:known-bug, r=nnethercote
Convert `tests/ui/lint/dead-code/self-assign.rs` to a known-bug test

I did a survey pass over `tests/`, and this test seems like the only candidate suitable for conversion into a known-bug test. (Other tests had varying degrees of other issues that known-bug would not be suitable.)

r? compiler
2025-04-13 17:37:55 -04:00
Jacob Pratt
1b6fcd9440
Rollup merge of #139674 - yotamofek:pr/mir_transform/index-iterators, r=compiler-errors
In `rustc_mir_transform`, iterate over index newtypes instead of ints

Just makes code more idiomatic/easier to read, IMHO.
Also, some drive-by simplifications and cleanups.
2025-04-13 17:37:55 -04:00
Jacob Pratt
388d612765
Rollup merge of #139644 - yotamofek:pr/mir_transform/instsimplify/simplify_primitive_clone, r=compiler-errors
Micro-optimize `InstSimplify`'s `simplify_primitive_clone`

r? ````@compiler-errors```` , since you already did #139411 and got randomly selected for #139638 (feel free to reassign!)

Another one similar in spirit to #139411, but this time for `simplify_primitive_clone`, which is doing a bit of redundant work. Might not show up in benches, but probably worth micro-optimizing since the transformation is run even for debug builds.

See inline comments for my reasoning for making these changes.
2025-04-13 17:37:54 -04:00
Jacob Pratt
a04a03720e
Rollup merge of #139628 - makai410:suggest-vis, r=compiler-errors
Suggest remove redundant `$()?` around `vis`

Resolves: #139480 .
2025-04-13 17:37:54 -04:00
Jacob Pratt
cd09162ac7
Rollup merge of #139582 - oli-obk:coercion-cleanups, r=compiler-errors
Various coercion cleanups

I think the commit order is the most reasonable one, but there's probably more ways to get to the same goal.

Essentially I got rid of the `simple` and `identity` helpers by adding a dedicated function for the common `identity` case and getting rid of the callbacks alltogether by realizing that all callbacks were of the pattern "use this fixed prefix list of adjustments, then add another adjustment with the unified type as the target type".

No behavioral changes intended
2025-04-13 17:37:53 -04:00
Jacob Pratt
346d33a5b7
Rollup merge of #139379 - matthewjasper:drop-elab-normalization, r=compiler-errors
Use delayed bug for normalization errors in drop elaboration

Normalization can fail due to a lot of different earlier errors, so just use span_delayed_bug if normalization failed.

Closes #137287
Closes #135668

r? compiler-errors
2025-04-13 17:37:53 -04:00
Jacob Pratt
7f691d28f1
Rollup merge of #139001 - folkertdev:naked-function-rustic-abi, r=traviscross,compiler-errors
add `naked_functions_rustic_abi` feature gate

tracking issue: https://github.com/rust-lang/rust/issues/138997

Because the details of the rust abi are unstable, and a naked function must match its stated ABI, this feature gate keeps naked functions with a rustic abi ("Rust", "rust-cold", "rust-call" and "rust-intrinsic") unstable.

r? ````@traviscross````
2025-04-13 17:37:52 -04:00
Jacob Pratt
60c76b9dfd
Rollup merge of #138962 - xizheyin:issue-138836, r=compiler-errors
Expect an array when expected and acutal types are both arrays during cast

Closes #138836
2025-04-13 17:37:52 -04: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
6e83046233 Auto merge of #131203 - clubby789:jumpthreading-not, r=compiler-errors
JumpThreading: fix bitwise not on non-booleans

Fixes #131195

Alternative to #131201
2025-04-13 21:36:59 +00:00
jyn
d50a8d5fb3 Improve -Z crate-attr diagnostics
- Show the `#![ ... ]` in the span (to make it clear that it should not
  be included in the CLI argument)
- Show more detailed errors when the crate has valid token trees but
  invalid syntax.
  Previously, `crate-attr=feature(foo),feature(bar)` would just say
  "invalid crate attribute" and point at the comma. Now, it explicitly
  says that the comma was unexpected, which is useful when using
  `--error-format=short`. It also fixes the column to show the correct
  span.
- Recover from parse errors. Previously we would abort immediately on
  syntax errors; now we go on to try and type-check the rest of the
  crate.

The new diagnostic code also happens to be slightly shorter.
2025-04-13 16:46:02 -04:00
clubby789
41a5d8ef3d JumpThreading: Bail out on interp errors 2025-04-13 20:29:51 +00:00
clubby789
9f35fe47c7 JumpThreading: Re-enable and fix Not ops on non-booleans 2025-04-13 20:29:49 +00:00
Vadim Petrochenkov
93bee0789a UI tests: migrate remaining compile time error-patterns to line annotations
when possible.
2025-04-13 21:48:53 +03: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
Jieyou Xu
957324b0a0
rustdoc-gui-test: pass a camino::Utf8PathBuf to compiletest 2025-04-13 19:59:35 +08:00
Jieyou Xu
e24b0c8e0a
compiletest: consistently use {Utf8Path,Utf8PathBuf}
Since compiletest already assumes UTF-8 paths and does not try to be
robust against non-UTF-8 paths.
2025-04-13 19:59:35 +08:00
Jieyou Xu
b203d40367
compiletest: add camino for UTF-8 path handling 2025-04-13 19:56:25 +08: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
54aff1f6ef
Rollup merge of #139721 - dtolnay:stage0newline, r=onur-ozkan
End all lines in src/stage0 with trailing newline

Most tools that process text files prefer if every line ends in \n. Text files without the last newline are aberrant and usually not what you want.

**Before:**

```console
$ cat src/stage0 src/stage0
dist_server=https://static.rust-lang.org
artifacts_server=https://ci-artifacts.rust-lang.org/rustc-builds
...
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.gz=986f6c594d37bcbd3833e053640ba8775f68d26a65c5618386654ef55d7b3542
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.xz=c0d9a88c30d2ab38ec3a11fabb5515ed9bc3ac1a8e35a438d68bf7ff82f6b843dist_server=https://static.rust-lang.org
artifacts_server=https://ci-artifacts.rust-lang.org/rustc-builds
...
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.gz=986f6c594d37bcbd3833e053640ba8775f68d26a65c5618386654ef55d7b3542
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.xz=c0d9a88c30d2ab38ec3a11fabb5515ed9bc3ac1a8e35a438d68bf7ff82f6b843$ ▌
```

**After:**

```console
$ cat src/stage0 src/stage0
dist_server=https://static.rust-lang.org
artifacts_server=https://ci-artifacts.rust-lang.org/rustc-builds
...
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.gz=986f6c594d37bcbd3833e053640ba8775f68d26a65c5618386654ef55d7b3542
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.xz=c0d9a88c30d2ab38ec3a11fabb5515ed9bc3ac1a8e35a438d68bf7ff82f6b843
dist_server=https://static.rust-lang.org
artifacts_server=https://ci-artifacts.rust-lang.org/rustc-builds
...
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.gz=986f6c594d37bcbd3833e053640ba8775f68d26a65c5618386654ef55d7b3542
dist/2025-04-02/rustc-nightly-x86_64-unknown-netbsd.tar.xz=c0d9a88c30d2ab38ec3a11fabb5515ed9bc3ac1a8e35a438d68bf7ff82f6b843
$ ▌
```
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
423e7b8286
Rollup merge of #139618 - petrochenkov:virsugg, r=jieyouxu
compiletest: Make `SUGGESTION` annotations viral

If one of them is expected in a test file, then others should be annotated as well, in the same way as with `HELP`s and `NOTE`s.
This doesn't require much of an additional annotation burden, but simplifies the rules.

r? ```@jieyouxu```
2025-04-13 11:48:17 +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
f1b31ae8df
Rollup merge of #139177 - fneddy:fix_s390x_codegen_bswap, r=Mark-Simulacrum
Use -C target-cpu=z13 on s390x vector test

currently we see a regression in the `dont-shuffle-bswaps.rs` on s390x. This is due to, the default s390x cpu is set to z10 [here](https://github.com/rust-lang/rust/blob/master/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs#L9) which does not have vector instructions implemented. To make the test pass we need to create an extra test revision and set target-cpu at least to `z13`.
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
zjp
6d5f6fd293 import rustc_smir::rustc_internal in run_driver! 2025-04-13 18:09:10 +08:00
zjp
6b2262ecde add missing extern crate rustc_middle in rustc_smir::run! docstring 2025-04-13 18:07:43 +08:00
Jieyou Xu
16334cdfd4
tests: convert tests/ui/lint/dead-code/self-assign.rs to known-bug 2025-04-13 17:33:55 +08: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
bors
fda35a6da6 Auto merge of #139724 - ChrisDenton:rollup-zhcdtzh, r=ChrisDenton
Rollup of 8 pull requests

Successful merges:

 - #139163 (indirect-const-stabilize the `exact_div` intrinsic)
 - #139276 (Revert "Disable `f16` on Aarch64 without `neon`")
 - #139315 (Switch `time` to `jiff` for time formatting in ICE dumps)
 - #139382 (Update windows-bindgen to 0.61.0)
 - #139688 (rustdoc-search: add unbox flag to Result aliases)
 - #139701 (docs: clarify uint exponent for `is_power_of_two`)
 - #139705 (Removed outdated ui test suite README, give reasons for disabled tests)
 - #139713 (Fix typo in documentation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-04-13 03:59:04 +00:00
Chris Denton
6b26d3c37c
Rollup merge of #139709 - tshepang:patch-5, r=Kobzol
bootstrap: fix typo in doc string
2025-04-13 03:07:09 +00:00
Chris Denton
c3027182d1
Rollup merge of #139708 - samueltardieu:push-onttwlpwurov, r=petrochenkov
Fix name of field in doc comment

Trivial doc fix
2025-04-13 03:07:08 +00:00
Chris Denton
34eca3b07c
Rollup merge of #139707 - Kobzol:fix-comment, r=jieyouxu
Fix comment in bootstrap

Didn't notice it in https://github.com/rust-lang/rust/pull/139588.

r? ````@jieyouxu````
2025-04-13 03:07:08 +00:00
Chris Denton
b0c0ff97b6
Rollup merge of #139691 - Kobzol:opt-dist-docs, r=jieyouxu
Document that `opt-dist` requires metrics to be enabled

Suggested in https://github.com/rust-lang/rust/pull/139686.
2025-04-13 03:07:07 +00:00
Chris Denton
546367ef69
Rollup merge of #139607 - reddevilmidzy:add-regression-test, r=petrochenkov
Add regression test for #127424

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

This ICE no longer reproduces, so it appears to have already been fixed.
This PR adds a regression test to ensure the issue doesn’t come back in the future.

Please let me know if there's anything I should improve or revise!
2025-04-13 03:07:06 +00: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
Folkert de Vries
f472cc8cd4
error on unsafe attributes in pre-2024 editions
the `no_mangle`, `link_section` and `export_name` attributes are exceptions, and can still be used without an unsafe in earlier editions
2025-04-13 01:22:59 +02:00
jackh726
accae530ce Move FlagComputation, PatternKind, and TypeWalker to rustc_type_ir 2025-04-12 22:46:11 +00:00