295492 Commits

Author SHA1 Message Date
Jubilee
b7a9cd871c
Rollup merge of #142923 - folkertdev:min-function-alignment-no-attributes, r=workingjubilee
fix `-Zmin-function-alignment` on functions without attributes

tracking issue: https://github.com/rust-lang/rust/issues/82232
related: https://github.com/rust-lang/rust/pull/142854

The minimum function alignment was skipped on functions without attributes (because the logic was in a loop that only runs if there is at least one attribute). The underlying reason we didn't catch this before is that in our testing we generally apply `#[no_mangle]` to functions that are tested. I've added a test now that deliberately has no attributes.

r? `@workingjubilee`
2025-06-23 12:48:23 -07:00
Jubilee
1569f14961
Rollup merge of #142922 - JonathanBrouwer:fix-rustdoc-comment, r=jdonszelmann
Fix comment on NoMangle

Fix comment on NoMangle.
This was discussed in comments of https://github.com/rust-lang/rust/pull/142823#discussion_r2162219576 and https://github.com/rust-lang/rust/pull/142921
2025-06-23 12:48:23 -07:00
Jubilee
64cfd5b6d2
Rollup merge of #142908 - psumbera:solaris-tr, r=jieyouxu
Fix install-template.sh for Solaris tr

Allow to run install.sh also on Solaris where tr is not GNU tr.
2025-06-23 12:48:22 -07:00
Jubilee
8ba8f1ef4c
Rollup merge of #142873 - Urgau:issue-139830, r=BoxyUwU
Don't suggest changing a  method inside a expansion

Fixes https://github.com/rust-lang/rust/issues/139830
r? compiler
2025-06-23 12:48:22 -07:00
Jubilee
b942c6d291
Rollup merge of #142827 - GuillaumeGomez:tidy-error-code-removal, r=Kobzol
Move error code explanation removal check into tidy

Follow-up of https://github.com/rust-lang/rust/pull/142677.

This PR replaces a shell script with rust code.

r? ghost
2025-06-23 12:48:21 -07:00
Jubilee
8ba69d0f95
Rollup merge of #142784 - Kobzol:timings-codegen, r=nnethercote
Add codegen timing section

And since we now start and end the sections also using separate functions, also add some light checking if we're generating the sections correctly.

I'm integrating `--timings` into Cargo, and I realized that the codegen timings would be quite useful for that. Frontend can be computed simply as `[start of compilation, start of codegen]` for now.

r? `@nnethercote`
2025-06-23 12:48:20 -07:00
Jubilee
ff1636b6e3
Rollup merge of #142134 - workingjubilee:reject-unsupported-abi, r=jdonszelmann,RalfJung
Reject unsupported `extern "{abi}"`s consistently in all positions

Modify the handling of `extern "{abi}"` in the compiler so that it has consistent errors without regard to the position in the grammar.

## What

Implement the following breakages:
- Promote [`unsupported_fn_ptr_calling_conventions`] from a warning to a hard error
- Guarantee future edge-cases like trait declarations will not escape so that *ABIs that have already been unusable in most positions* will now be unusable in **all positions**. See "How" and "Why or Why Not" for more details.

In particular, these architecture-specific ABIs now only compile on their architectures[^4]:
  - amdgpu: "gpu-kernel"
  - arm: "aapcs", "C-cmse-nonsecure-entry", "C-cmse-nonsecure-call"
  - avr: "avr-interrupt", "avr-non-blocking-interrupt"
  - msp430: "msp430-interrupt"
  - nvptx64: "gpu-kernel", "ptx-kernel"
  - riscv32 and riscv64: "riscv-interrupt-m", "riscv-interrupt-s"
  - x86: "thiscall"
  - x86 and x86_64: "x86-interrupt"
  - x86_64: "sysv64", "win64"

ABIs that are logically x86-specific but actually permitted on all Windows targets remain permitted on Windows, as before. For non-Windows targets, they error if we had previously done so in other positions.

## How

We modify rustc_ast_lowering to prevent unsupported ABIs from leaking through the HIR without being checked for target support. They now emit hard errors for every case where we would return `Invalid` from `AbiMap::canonize_abi`. Previously ad-hoc checking on various HIR items required making sure we check every HIR item which could contain an `extern "{abi}"` string. This is a losing proposition compared to gating the lowering itself.

As a consequence, unsupported ABI strings error instead of triggering the warning `unsupported_fn_ptr_calling_conventions`. The code is also simpler compared to alternative implementations that might e.g. split on unstable vs. stable, only suffering some unavoidable complication to support the newly-revived `unsupported_calling_conventions` lint.[^5]

However, per rust-lang/rust#86232 this does cause errors for rare usages of `extern "{abi}"` that were theoretically possible to write in Rust source, without previous warning or error. For instance, trait declarations without impls were never checked. These are the exact kinds of leakages that this new approach prevents.

This differs from the following PRs:
- rust-lang/rust#141435 is orthogonal, as it adds a new lint for ABIs we have not warned on and are not touched by this PR
- rust-lang/rust#141877 is subsumed by this, in that this simply cuts out bad functionality instead of adding epicycles for stable code

## Why or Why Not

We already made the decision to issue the `unsupported_fn_ptr_calling_conventions` future compatibility warning. It has warned in dependencies since rust-lang/rust#135767, which reached stable with Rust 1.87. That was released on 2025 May 17, and it is now June. As we already had erred on these ABI strings in most other positions, and warn on stable for function pointer types, this breakage has had reasonable foreshadowing.

Upgrading the warning to an error addresses a real problem. In some cases the Rust compiler can attempt to actually compute the ABI for calling a function with an unsupported ABI. We could accept this case and compute unsupported ABIs according to some other ABI, silently[^6]. However, this obviously exposes Rust to errors in codegen. We cannot lower directly to the "obvious", target-incorrect ABI and then trust code generators like LLVM to reliably error on these cases, either.

Other considerations include:
- We could refactor the compiler to defer ABI computations, but that seems like it would suffer the "whack-a-mole" problem close to linking instead of after parsing and expansion.
- We could run a deprecation cycle for the edge cases, but we would be warning highly marginal cases, like this trait declaration without a definition that cannot be implemented without error[^9].
```rust
pub trait UsedToSneakBy {
    pub extern "gpu-kernel" fn sneaky();
}
```
- The [crater run] on this PR's draft form suggests the primary issue is with implementations on function pointers, which has already been warned on, so it does not seem like we would be benefiting any real code.
- Converting this to a hard error now, in the same cycle that we ship the reanimation of the `unsupported_calling_conventions` lint, means people who would otherwise have to deal with two lints only have to update their code in one batch. Of course, one of them is as breakage.

r? lang

Fixes rust-lang/rust#86232
Fixes rust-lang/rust#132430
Fixes rust-lang/rust#138738
Fixes rust-lang/rust#142107

[`unsupported_fn_ptr_calling_conventions`]: https://github.com/rust-lang/rust/issues/130260
[crater run]: https://github.com/rust-lang/rust/pull/142134#issuecomment-2953837506
[^9]: Upon any impl, even for provided fn within trait declarations, e.g. `pub extern "gpu-kernel" fn sneaky() {}`, different HIR types were used which would, in fact, get checked. Likewise for anything with function pointers. Thus we would be discussing deprecation cycles for code that is impotent or forewarned[^7].
[^4]: Some already will not compile, due to reaching ICEs or LLVM errors.
[^5]: That lint cannot be moved in a similar way yet because lints operate on HIR, so you cannot emit lints when the HIR has not been completely formed.
[^6]:  We already do this for all `AbiStr` we cannot parse, pretending they are `ExternAbi::Rust`, but we also emit an error to prevent reaching too far into codegen.
[^7]: It actually did appear in two cases in rustc's test suite because we are a collection of Rust edge-cases by the simple fact that we don't care if the code actually runs. These cases are being excised in 643a9d233b4f1547220134daea4bcca809302d40
2025-06-23 12:48:20 -07:00
Jubilee
fc3d7ee7b7
Rollup merge of #141324 - Ayush1325:uefi-rand-fallback, r=joboet
std: sys: random: uefi: Provide rdrand based fallback

Some UEFI systems based on American Megatrends Inc. v3.3 do not provide RNG support [1]. So fallback to rdrand in such cases.

[1]: https://github.com/rust-lang/rust/issues/138252#issuecomment-2891270323

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

cc `@seijikun`
2025-06-23 12:48:19 -07:00
Jubilee
f50da063e8
Rollup merge of #140985 - zachs18:fuse-default-some, r=tgross35
Change `core::iter::Fuse`'s `Default` impl to do what its docs say it does

The [docs on `impl<I: Default> Default for core::iter::Fuse<I>`](https://doc.rust-lang.org/nightly/std/iter/struct.Fuse.html#impl-Default-for-Fuse%3CI%3E) say (as the `I: Default` bound implies) that `Fuse::<I>::default` "Creates a `Fuse` iterator from the default value of `I`". However, the implementation creates a `Fuse` with `Fuse { iter: Default::default() }`, and since the `iter` field is an `Option<I>`, this is actually `Fuse { iter: None }`, not `Fuse { iter: Some(I::default()) }`, so `Fuse::<I>::default()` always returns an empty iterator, even if `I::default()` would not be empty.

This PR changes `Fuse`'s `Default` implementation to match the documentation. This will be a behavior change for anyone currently using `Fuse::<I>::default()` where `I::default()` is not an empty iterator[^1], as `Fuse::<I>::default()` will now also not be an empty iterator.

(Alternately, the docs could be updated to reflect what the current implementation actually does, i.e. returns an always-exhausted iterator that never yields any items (even if `I::default()` would have yielded items). With this option, the `I: Default` bound could also be removed to reflect that no `I` is ever created.)

[Current behavior example](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=a1e0adc4badca3dc11bfb70a99213249) (maybe an example like this should be added to the docs either way?)

This PR changes publicly observable behavior, so I think requires at least a T-libs-api FCP?

r? libs-api

cc https://github.com/rust-lang/rust/issues/140961

`impl<I: Default> Default for Fuse<I>` was added in 1.70.0 (https://github.com/rust-lang/rust/pull/99929), and it's docs and behavior do not appear to have changed since (`Fuse`'s `iter` field has been an `Option` since before the impl was added).

[^1]: IIUC it is a "de facto" guideline for the stdlib that an iterator type's `default()` should be empty (and for iterators where that would not make sense, they should not implement `Default`): cc https://github.com/rust-lang/libs-team/issues/77#issuecomment-1194681709 , so for stdlib iterators, I don't think this would change anything. However, if a user has a custom `Iterator` type `I`, *and* they are using `Fuse<I>`, *and* they call `Fuse::<I>::default()`, this may change the behavior of their code.
2025-06-23 12:48:18 -07:00
Folkert de Vries
8147646531
fix -Zmin-function-alignment without attributes
the minimum function alignment was skipped on functions without attributes. That is because in our testing we generally apply `#[no_mangle]` to functions that are tested. I've added a test now that deliberately has no attributes
2025-06-23 20:26:04 +02:00
Jonathan Brouwer
6ea79a13b5
Fix comment on NoMangle
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-06-23 20:24:54 +02:00
Jubilee Young
aa25b9b116 tests: Bless cannot-be-called and dedup with unsupported ABI test 2025-06-23 09:40:00 -07:00
Jubilee Young
78528bc0e6 tests: Verify varargs with unsupported fn ptr ABIs must error 2025-06-23 09:40:00 -07:00
Jubilee Young
7632fab668 tests: Adopt ABI transmute tests from crashtests 2025-06-23 09:40:00 -07:00
Jubilee Young
0dd29e1a86 tests: Update and bless cmse-nonsecure ABI tests 2025-06-23 09:40:00 -07:00
Jubilee Young
a3a6d9bf71 tests: Update raw-dylib unsupported ABI test 2025-06-23 09:40:00 -07:00
Jubilee Young
7e35b284e1 tests: Enhance unsupported ABI tests
We have fairly different error messages now and handle more cases,
so we augment the test in tests/ui/abi/unsupported.rs with more examples
to handle structs, traits, and impls on same when those feature
the unsupported ABIs of interest.
2025-06-23 09:40:00 -07:00
Jubilee Young
a69aeaf1e3 tests: Bless abi_gpu_kernel feature gate test 2025-06-23 09:40:00 -07:00
Ralf Jung
7c6b50cd5b unsupported_calling_conventions: print which ABI this is about 2025-06-23 09:40:00 -07:00
Jubilee Young
267ecd132b Clarify note in rustc_ast_lowering still applies
Co-authored-by: Ralf Jung <post@ralfj.de>
2025-06-23 09:40:00 -07:00
Jubilee Young
b34c52043f compiler: Remove unsupported_fn_ptr_calling_conventions lint 2025-06-23 09:39:59 -07:00
Jubilee Young
e93a99b324 hir_analysis: Avoid repeating unsupported ABI errors 2025-06-23 09:39:23 -07:00
Jubilee Young
2f4a55b41d compiler: plug unsupported ABI leakage from the AST
We modify rustc_ast_lowering to prevent all unsupported ABIs
from leaking through the HIR without being checked for target support.
Previously ad-hoc checking on various HIR items required making sure
we check every HIR item which could contain an `extern "{abi}"` string.
This is a losing proposition compared to gating the lowering itself.

As a consequence, unsupported ABI strings will now hard-error instead of
triggering the FCW `unsupported_fn_ptr_calling_conventions`.
This FCW was upgraded to warn in dependencies in Rust 1.87 which was
released on 2025 May 17, and it is now 2025 June, so it has become
active within a stable Rust version.

As we already had errored on these ABIs in most other positions, and
have warned for fn ptrs, this breakage has had reasonable foreshadowing.

However, this does cause errors for usages of `extern "{abi}"` that were
theoretically writeable within source but could not actually be applied
in any useful way by Rust programmers without either warning or error.
For instance, trait declarations without impls were never checked.
These are the exact kinds of leakages that this new approach prevents.

A deprecation cycle is not useful for these marginal cases as upon impl,
even default impls within traits, different HIR objects would be used.
Details of our HIR analysis meant that those objects did get checked.

We choose to error twice if an ABI is also barred by a feature gate
on the presumption that usage of a target-incorrect ABI is intentional.

Co-authored-by: Ralf Jung <post@ralfj.de>
2025-06-23 09:39:23 -07:00
bors
706f244db5 Auto merge of #142907 - lnicola:sync-from-ra, r=lnicola
Subtree update of `rust-analyzer`

r? `@ghost`
2025-06-23 15:57:38 +00:00
bors
42245d34d2 Auto merge of #142906 - jdonszelmann:rollup-togt1dl, r=jdonszelmann
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#142493 (rework `#[naked]` attribute parser)
 - rust-lang/rust#142636 (bootstrap.example.toml: use less contextual format)
 - rust-lang/rust#142822 (Make `PartialEq` a `const_trait`)
 - rust-lang/rust#142892 (Fix ICE on debug builds where lints are delayed on the crate root)
 - rust-lang/rust#142904 (notify me when rdg is touched)

Failed merges:

 - rust-lang/rust#142827 (Move error code explanation removal check into tidy)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-23 12:38:27 +00:00
Petr Sumbera
c7bfb114b7 Fix install-template.sh for Solaris tr 2025-06-23 13:16:08 +02:00
Guillaume Gomez
4780f21fe5 Move error code explanation removal check into tidy 2025-06-23 13:16:00 +02:00
Guillaume Gomez
66060e6475 Create new CiInfo type in tidy checks to centralize CI related checks 2025-06-23 13:15:58 +02:00
Jana Dönszelmann
3e8e06545e
Rollup merge of #142904 - tshepang:patch-1, r=jieyouxu
notify me when rdg is touched

r? jieyouxu
2025-06-23 12:39:09 +02:00
Jana Dönszelmann
6cee0a6ead
Rollup merge of #142892 - jdonszelmann:fix-142891, r=oli-obk
Fix ICE on debug builds where lints are delayed on the crate root

r? ``@oli-obk``

Closes rust-lang/rust#142891

thanks to ``@JonathanBrouwer`` for finding it!
2025-06-23 12:39:09 +02:00
Jana Dönszelmann
c8df66f84c
Rollup merge of #142822 - oli-obk:const-partial-eq, r=fee1-dead
Make `PartialEq` a `const_trait`

r? ``@fee1-dead`` or ``@compiler-errors``

something generally useful but also required for https://github.com/rust-lang/rust/pull/142789
2025-06-23 12:39:08 +02:00
Jana Dönszelmann
7df08be62c
Rollup merge of #142636 - lolbinarycat:bootstrap-example-unsection, r=Kobzol
bootstrap.example.toml: use less contextual format

prefixing each key with its section means you don't need to scroll up 4 pages to see which section
a particular key is from.

target specific options were kept in old format since the exact section name depends on the target, so those options must now be moved to the bottom of the file.

[inspired by zulip discussion](https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/consider.20rewriting.20bootstrap.2Eexample.2Etoml.20to.20use.20section.2Ekey/with/521734873)

r? ``@workingjubilee``
2025-06-23 12:39:07 +02:00
Jana Dönszelmann
b44d0c7da4
Rollup merge of #142493 - jdonszelmann:naked, r=oli-obk
rework `#[naked]` attribute parser

r? ``@oli-obk``
2025-06-23 12:39:07 +02:00
Jana Dönszelmann
5c0a625205
move naked checks out of check_attr.rs 2025-06-23 12:22:57 +02:00
Jana Dönszelmann
73bcf4c117
make warnings methods on cx so it's easier to emit them elsewhere too 2025-06-23 12:21:44 +02:00
Jana Dönszelmann
82cbc3a35e
rewrite #[naked] parser 2025-06-23 12:21:43 +02:00
Jana Dönszelmann
269b67d6b8
fix 142891 2025-06-23 12:20:02 +02:00
Jana Dönszelmann
2313d4c571
test for lint on root node crash 2025-06-23 12:17:57 +02:00
bors
ae2fc9722f Auto merge of #142792 - cuviper:version-1.90, r=cuviper
Bump the version number to 1.90.0

Part of the release process. This PR must not be rolled up.

r? cuviper
2025-06-23 09:36:06 +00:00
Tshepang Mbambo
9dd7bcb75a notify me when rdg is touched 2025-06-23 11:33:23 +02:00
Oli Scherer
993344257d Make PartialEq a const_trait 2025-06-23 08:45:26 +00:00
Jakub Beránek
332ae3b7e6
Add codegen timing section 2025-06-23 08:50:17 +02:00
bors
22be76b7e2 Auto merge of #142901 - matthiaskrgr:rollup-topt4p6, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#141597 (Document subdirectories of UI tests with README files)
 - rust-lang/rust#142823 (Port `#[no_mangle]` to new attribute parsing infrastructure)
 - rust-lang/rust#142828 (1.88.0 release notes)
 - rust-lang/rust#142854 (centralize `-Zmin-function-alignment` logic)
 - rust-lang/rust#142875 (Check rustdoc-json-types FORMAT_VERSION is correctly updated)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-06-23 06:37:23 +00:00
Matthias Krüger
110492092c
Rollup merge of #142875 - GuillaumeGomez:rustdoc-json-types-version-update, r=Kobzol
Check rustdoc-json-types FORMAT_VERSION is correctly updated

Follow-up of https://github.com/rust-lang/rust/pull/142677.

``@nnethercote`` suggested that we should also ensure that the `FORMAT_VERSION` was only increased by 1 and we should check for it, this PR does it.

cc ``@aDotInTheVoid``
r? ghost
2025-06-23 06:07:21 +02:00
Matthias Krüger
57abad8cc5
Rollup merge of #142854 - folkertdev:centralize-min-function-alignment, r=workingjubilee
centralize `-Zmin-function-alignment` logic

tracking issue: https://github.com/rust-lang/rust/issues/82232
discussed in: https://github.com/rust-lang/rust/pull/142824#discussion_r2160056244

Apply the `-Zmin-function-alignment` value to the alignment field of the function attributes when those are created, so that individual backends don't need to consider it.

The one exception right now is cranelift, because it can't yet set the alignment for individual functions, but it can (and does) set the global minimum function alignment.

cc ``@RalfJung`` I think this is an improvement regardless, is there anything else that should be done for miri?
2025-06-23 06:07:20 +02:00
Matthias Krüger
2357fb05bb
Rollup merge of #142828 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum
1.88.0 release notes

r? cuviper
2025-06-23 06:07:20 +02:00
Matthias Krüger
9b6665fafa
Rollup merge of #142823 - JonathanBrouwer:no_mangle_parser, r=jdonszelmann
Port `#[no_mangle]` to new attribute parsing infrastructure

Ports `no_mangle` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971353197

r? ``@jdonszelmann``
2025-06-23 06:07:19 +02:00
Matthias Krüger
f63fdde764
Rollup merge of #141597 - Oneirical:unquestionable-instruction, r=jieyouxu
Document subdirectories of UI tests with README files

Part of rust-lang/rust#133895 and the [2025 Google Summer of Code](https://blog.rust-lang.org/2025/05/08/gsoc-2025-selected-projects/) associated project.

When adding a new UI test, one is faced with hundreds of subdirectories in `tests/ui` reflecting various categories. Knowing where to put the new test is not trivial, as many of the categories have slightly misleading names. For example, `moves` does not only refer to the `move` keyword but to functions taking ownership in general, whereas `allocator` does not refer to allocation in general but rather to the very specific `allocator_api` and `global_allocator` features.

Many contributors will therefore place their test at the top level of ̀`tests/ui` where it will be mixed with hundreds of unrelated tests.

This PR is a tentative move towards more clearly defined tag/categories, with a SUMMARY.md file documenting the true purpose of each subdirectory, placed inside `tests/ui`.

r? ``@jieyouxu``
2025-06-23 06:07:19 +02:00
bors
58d5e11690 Auto merge of #142898 - ehuss:update-cargo, r=ehuss
Update cargo

7 commits in 2251525ae503fa196f6d7f9ce6d32eccb2d5f044..84709f085062cbf3c51fa507527c1b2334015178
2025-06-16 22:01:27 +0000 to 2025-06-22 23:58:39 +0000
- Bump cargo-util-schemas version (rust-lang/cargo#15696)
- test(msrv): use a far future "newer" version (rust-lang/cargo#15693)
- Plumb rustc `-Zhint-mostly-unused` flag through as a profile option (rust-lang/cargo#15643)
- Disable lldb test, which seems to be broken due to issues with lldb (rust-lang/cargo#15687)
- docs(contrib): change clap URL to docs.rs/clap (rust-lang/cargo#15682)
- feat: Introduce perma unstable `--compile-time-deps` option for `cargo build` (rust-lang/cargo#15674)
- fix: Failing tests on rustc nightly (rust-lang/cargo#15679)
2025-06-23 03:38:39 +00:00
Eric Huss
74973d72fd Update cargo 2025-06-22 17:43:06 -07:00