Commit Graph

327705 Commits

Author SHA1 Message Date
bors 40871faace Auto merge of #157100 - oli-obk:some_more_per_owner_things, r=<try>
Some more per owner things
2026-05-29 08:51:01 +00:00
Oli Scherer b69baba8bc Track lifetimes_res_map per owner 2026-05-29 10:34:21 +02:00
Oli Scherer 87c7663ee3 Track label_res_map per-owner 2026-05-29 10:30:08 +02:00
Oli Scherer 74ad9d3872 Track lifetime_elision_allowed per owner, and discard fn ptr and Fn() syntax registrations of it, they are never used 2026-05-29 10:27:59 +02:00
Oli Scherer 335a6674e9 Use default field values to avoid some churn 2026-05-29 10:25:37 +02:00
bors dc375db7d8 Auto merge of #156634 - Paladynee:lib/array-intoiter-spec-clone, r=joboet
lib: specialize Clone of array IntoIter



This PR adds the `TrivialClone` specialization to the `PolymorphicIter` type, which `array::IntoIter` uses. I also added another coretest for the default case (already existing test catches the specialized one).

There are no unwinding concerns since `TrivialClone` means cloning = copying and we never call `Clone::clone`.

`array:IntoIter` is being used on a lot of places in both `core` and in user code, and `array::IntoIter` (nor does its users) override `Clone` often and just delegate to the inner type `PolymorphicIter` which does not yet do the `TrivialClone` specialization and is burdened by the iterator and unwind safety shenanigans for all types, so this PR should address some of that. This should in turn slightly reduce both stack usage and remove unwinding prologue/epilogue etc. from such functions and improve our `-Cno-prepopulate-passes` codegen too.

perf: https://godbolt.org/z/eTPjj3hP3
2026-05-29 01:56:03 +00:00
bors cced03bfd6 Auto merge of #157007 - Kobzol:reject-invalid-backend, r=jieyouxu
Reject invalid codegen backends on CI

The way we set codegen backends in CI jobs contained several bugs.

1) We didn't check if the specified codegen backend is valid. That can be useful in forks, but not on our CI, there it should be a loud error.
2) The codegen backends were specified with weird quoting that was (I think) producing invalid backends.
3) The specified backends in `RUST_CONFIGURE_ARGS` were being overridden due to `run.sh` setting codegen backends based on the `CODEGEN_BACKENDS` environment variable (see https://github.com/rust-lang/rust/pull/156989).

This PR should fix all of these.

After doing some CI runs on this PR, I realized that setting `CODEGEN_BACKENDS` from within the Dockerfile doesn't work, because we use `docker run --env CODEGEN_BACKENDS`, and that will unset the inner env even if the same env is not actually configured in the environment from where `docker run` is executed (sigh). So instead I decided to pass the env variables from `jobs.yml`. It's not really pretty, but it is a solution that should work with the current structure.
2026-05-28 16:32:43 +00:00
bors 8c1d72083b Auto merge of #157064 - JonathanBrouwer:rollup-BDFNumV, r=JonathanBrouwer
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#157046 (file locking: clarify that double-locking is underspecified)
 - rust-lang/rust#156401 (rustdoc: deterministic sorting for `doc_cfg` badges)
 - rust-lang/rust#156746 (cg_llvm: Use `LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision`)
 - rust-lang/rust#156889 (Suggest function-local constructors without enclosing function path)
 - rust-lang/rust#157012 (Fix missing note of escaping `{` for braces including whitespaces)
 - rust-lang/rust#157056 (Update Xtensa target data layouts to match upstream LLVM)
 - rust-lang/rust#157062 (Add link to RFMF Sponsors page)
2026-05-28 13:21:14 +00:00
Jonathan Brouwer 5cd06d1843 Rollup merge of #157062 - Kobzol:sponsors-link, r=Mark-Simulacrum,jieyouxu
Add link to RFMF Sponsors page

To make the funding/sponsor link to RFMF and the Foundation's Sponsors page simpler.
2026-05-28 14:59:46 +02:00
Jonathan Brouwer c727a400b5 Rollup merge of #157056 - esp-rs:update-xtensa-datalayout, r=folkertdev
Update Xtensa target data layouts to match upstream LLVM

Born from https://github.com/rust-lang/rust/pull/156568#issuecomment-4563228595.

We've been using a fork to distribute compiler builds that support the Xtensa arch whilst we're upstreaming. At a certain point we received some changes on our fork, which haven't been upstreamed, which I now to believe to be a mistake - therefore I'm reverting to the upstream LLVM datalayout.

r? @folkertdev
2026-05-28 14:59:45 +02:00
Jonathan Brouwer b03615be22 Rollup merge of #157012 - Kokoro2336:fix/issue-156868, r=mejrs
Fix missing note of escaping `{` for braces including whitespaces

Fixes rust-lang/rust#156868

Add note of escaping `{` for braces including whitespaces
2026-05-28 14:59:44 +02:00
Jonathan Brouwer 5bc1fd171c Rollup merge of #156889 - onehr:fix-local-tuple-constructor-suggestion-144319, r=jieyouxu
Suggest function-local constructors without enclosing function path

Closes rust-lang/rust#144319

This fixes a mismatched-type wrapper suggestion for constructors defined inside
function-like scopes. The previous diagnostic used `def_path_str` directly, so a
function-local tuple struct could be suggested as `main::Foo(false)`, even though
`main` is not a module path that can name the constructor.

The suggestion now prints the constructor path under rustc's existing suggestion
printer mode. That mode omits path segments that cannot be written in source,
while preserving real path segments such as local modules and enum names.

The regression test covers:

- a function-local tuple struct constructor
- a function-local enum variant
- a tuple struct inside a function-local module
- a tuple struct inside a closure body
- a tuple struct inside an inline const block
2026-05-28 14:59:43 +02:00
Jonathan Brouwer 49bbe8aca7 Rollup merge of #156746 - Zalathar:llvm-debuginfo, r=jieyouxu
cg_llvm: Use `LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision`

- Part of https://github.com/rust-lang/rust/issues/134001
- Follow-up to https://github.com/rust-lang/rust/pull/146763
---

This PR replaces our custom `LLVMRustDIBuilderCreateEnumerator` FFI binding with an equivalent LLVM-C binding to `LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision`, which was introduced in LLVM 21.

I have also added comments to the remaining `LLVMRustDIBuilder` functions explaining why they currently can't use an LLVM-C binding, and noted some other functions that can use LLVM-C bindings in the future.
2026-05-28 14:59:42 +02:00
Jonathan Brouwer b0d9ae60e1 Rollup merge of #156401 - shivendra02467:doc-cfg-sort-fix, r=GuillaumeGomez
rustdoc: deterministic sorting for `doc_cfg` badges

Fixes rust-lang/rust#156391

Currently, target-exclusive `doc_cfg` badges (eg. "Available on...") reuse the order of predicates as they appear in the source code. This often buries popular targets behind niche ones and leads to inconsistent UI rendering.

This PR introduces a deterministic sorting mechanism to the `Cfg` AST prior to HTML/JSON rendering.

**Note for Reviewers:**
To provide the best UX, I implemented a lightweight tiering heuristic (prioritizing major platforms like Linux/Apple/Windows first, followed by mobile, then BSDs, and alphabetizing the rest). However, I am completely open to tweaking these priority groupings or falling back to a different sorting logic if the team prefers. Let me know what you think!
2026-05-28 14:59:41 +02:00
Jonathan Brouwer 22f9a1d46d Rollup merge of #157046 - RalfJung:file_lock_double_unlock, r=Mark-Simulacrum
file locking: clarify that double-locking is underspecified

The 2nd commit fixes https://github.com/rust-lang/rust/issues/157045 by making the docs more clear.
2026-05-28 14:59:40 +02:00
Jakub Beránek 840b3ce59e Add link to RFMF Sponsors page 2026-05-28 14:25:11 +02:00
Scott Mabin d061e0b19f Update Xtensa target data layouts to match upstream LLVM changes 2026-05-28 11:53:38 +01:00
Shivendra Sharma f658bf6bb8 rustdoc: deterministic sorting for doc_cfg badges 2026-05-28 16:15:20 +05:30
Ralf Jung 2c1d605504 make file locking docs a bit more clear 2026-05-28 11:24:57 +02:00
Ralf Jung a3b82407cc enable file_lock_double_unlock test on Unix targets as well
and make it cover the specific difference between Windows and Unix
2026-05-28 11:18:07 +02:00
bors b5e038d715 Auto merge of #157048 - JonathanBrouwer:rollup-2S3ck2Y, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#156568 (Fix Xtensa vaarg stack transition algorithm)
 - rust-lang/rust#156659 (coverage: Build the expansion tree around `SyntaxContext`)
 - rust-lang/rust#156941 (Offload: Update confusing and outdated file name)
2026-05-28 09:17:14 +00:00
Jonathan Brouwer 2456df10c4 Rollup merge of #156941 - ZuseZ4:update-offload-file-naming, r=oli-obk
Offload: Update confusing and outdated file name

We swapped the order in which we do host and device compilations. The file getting renamed is effectively the output of the clang-offload-packager, the first magic bytes (`00000000  10 ff 10 ad`) confirm it. I was just creating a figure to visualize and noticed that the name is off.

cc @Kevinsala @jdoerfert is there any naming convention?

r? oli-obk
2026-05-28 10:36:45 +02:00
Jonathan Brouwer fdf56d2cf4 Rollup merge of #156659 - Zalathar:syntax-context, r=oli-obk
coverage: Build the expansion tree around `SyntaxContext`

The expansion tree was previously built around `ExpnId`, which was subtly incorrect in cases where multiple distinct syntax contexts share the same `outer_expn` ID. This can occur in the presence of nested macro expansions.

This change turns out to be fairly straightforward, because in all cases we were obtaining `ExpnId` from `span.ctxt().outer_expn()` anyway, so we can just remove the call to `.outer_expn()` and use the context instead.

As a result of this change, `context-mismatch-issue-147339.rs` no longer triggers a context mismatch in `extract_refined_covspans`, so this PR is a more principled fix for https://github.com/rust-lang/rust/issues/147339.
2026-05-28 10:36:44 +02:00
Jonathan Brouwer 3c533ce81d Rollup merge of #156568 - SergioGasquez:fix/xtensa-vaarg-alg, r=folkertdev
Fix Xtensa vaarg stack transition algorithm

Fixes Xtensa va arg stack transition algorithm
2026-05-28 10:36:43 +02:00
bors 59bc26c764 Auto merge of #157044 - matthiaskrgr:rollup-BX6I8YG, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#156932 (relnotes for 1.96)
 - rust-lang/rust#156403 (Add `TypeId` methods `variants` `fields` `field` for `type_info`)
 - rust-lang/rust#156797 (Suggest adding quotation marks to identifiers in attributes)
 - rust-lang/rust#157014 (Allow building the source tarballs while offline)
 - rust-lang/rust#157023 (`#[expect]` is an attribute valid for outer style)
 - rust-lang/rust#157025 (Show crate root path in misplaced crate-level attribute diagnostic)
2026-05-28 05:54:18 +00:00
Matthias Krüger 89777addb4 Rollup merge of #157025 - Dnreikronos:fix/crate-root-path-help-in-attr-style-diagnostic, r=JonathanBrouwer
Show crate root path in misplaced crate-level attribute diagnostic

Fixes rust-lang/rust#157001

If you put `#![feature(...)]` inside a non-root module, the diagnostic tells you it can only be used at the crate root, but never says where the crate root actually is. Not great if you're new to Rust or working in a big workspace with nested modules.

Now the diagnostic includes a help line with the crate root file path when the misplaced attribute is an inner attribute. Outer attributes already get a span note pointing at what they're applied to, so they don't need this. Path goes through `RemapPathScopeComponents::DIAGNOSTICS` so `--remap-path-prefix` is respected.

```
warning: the `#![feature]` attribute can only be used at the crate root
  --> src/foo.rs:1:1
   |
LL | #![feature(test)]
   | ^^^^^^^^^^^^^^^^^
   |
   = help: the crate root is at `src/main.rs`
```
2026-05-28 07:53:38 +02:00
Matthias Krüger 72777313f3 Rollup merge of #157023 - samueltardieu:push-mwykwuslpolq, r=nnethercote
`#[expect]` is an attribute valid for outer style
2026-05-28 07:53:38 +02:00
Matthias Krüger 0578fb7c84 Rollup merge of #157014 - bjorn3:source_tarball_offline, r=jieyouxu
Allow building the source tarballs while offline

Previously locally vendored dependencies wouldn't be reused when building the source tarball, instead everything would be downloaded from the internet again (if not in the cargo cache).

Fixes https://github.com/rust-lang/rust/issues/156982
2026-05-28 07:53:37 +02:00
Matthias Krüger c67006e139 Rollup merge of #156797 - ariagivens:suggest-quotes, r=JonathanBrouwer
Suggest adding quotation marks to identifiers in attributes

When the user provides an identifier when a literal was expected in an attribute value, suggest adding quotation marks to the identifier to make it a string literal.

For instance:
```
error: attribute value must be a literal
  --> $DIR/crate-type-non-crate.rs:9:16
   |
LL | #[crate_type = lib]
   |                ^^^ help: try adding quotation marks: `"lib"`
```
2026-05-28 07:53:36 +02:00
Matthias Krüger ac7ba99209 Rollup merge of #156403 - SpriteOvO:type-info-refactor-variant, r=oli-obk
Add `TypeId` methods `variants` `fields` `field` for `type_info`

Tracking issue rust-lang/rust#146922

- Adds `fn TypeId::variants` returns the number of variants, for struct and union and primitive types, it's always 1.
- Adds `fn TypeId::fields` returns the number of fields.
- Adds `fn TypeId::field` returns a field representing type `FieldId`.
- Adds a new type `FieldId`, which is a wrapper of `FieldRepresentingType`'s `TypeId`.

For methods `{fields,field}`, if indexing out of bounds, a compile-time error will be raised.

Regarding the removal of `Type` items, this will be done in a later PR in one go.

r? @oli-obk
2026-05-28 07:53:35 +02:00
Matthias Krüger 54352a0804 Rollup merge of #156932 - BoxyUwU:relnotes_1_96_0, r=cuviper
relnotes for 1.96

r? @cuviper

cc @rust-lang/release
2026-05-28 07:53:35 +02:00
Josh Stone 63d96cbcc7 Fix assert_matches! link 2026-05-27 22:51:55 -07:00
Josh Stone dd6f520f7e clean up spaces and add a rustdoc anchor 2026-05-27 20:49:44 -07:00
Josh Stone fd3b569601 Apply suggestions from code review
Co-authored-by: Josh Stone <cuviper@gmail.com>
Co-authored-by: alexey semenyuk <alexsemenyuk88@gmail.com>
2026-05-27 20:47:04 -07:00
Zalathar 03de21ecc5 coverage: Build the expansion tree around SyntaxContext
The expansion tree was previously built around `ExpnId`, which was subtly
incorrect in cases where multiple distinct syntax contexts share the same
`outer_expn` ID. This can occur in the presence of nested macro expansions.

This change turns out to be fairly straightforward, because in all cases we
were obtaining `ExpnId` from `span.ctxt().outer_expn()` anyway, so we can just
remove the call to `.outer_expn()` and use the context instead.

As a result of this change, `context-mismatch-issue-147339.rs` no longer
triggers a context mismatch in `extract_refined_covspans`.
2026-05-28 12:51:40 +10:00
Zalathar d59cae8cf1 Note some bindings that can be replaced after dropping LLVM 21 support 2026-05-28 12:47:38 +10:00
Zalathar 12ad5b7c52 Explain why the remaining debuginfo bindings don't use LLVM-C 2026-05-28 12:38:26 +10:00
Zalathar c8449aa958 Use LLVMDIBuilderCreateEnumeratorOfArbitraryPrecision 2026-05-28 12:38:26 +10:00
bors 8f02e856be Auto merge of #157037 - tgross35:update-builtins, r=tgross35
compiler-builtins subtree update

Subtree update of `compiler-builtins` to https://github.com/rust-lang/compiler-builtins/commit/8bf32936feec8c4cca6d56c7ab46c3631d37485c.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-05-28 01:53:52 +00:00
Dnreikronos 8db956b55d Move multi-file test to use auxiliary/ directory layout
Place submod.rs under tests/ui/attributes/auxiliary/ and use
#[path] to include it, matching the preferred compiletest
test structure. Removes the need for //@ ignore-auxiliary.
2026-05-27 20:55:46 -03:00
Asuna b513e539c3 FieldId wraps FRT TypeId instead of the actual field TypeId 2026-05-27 22:25:09 +00:00
Dnreikronos 59debaf661 Mark submod.rs as auxiliary so compiletest skips it 2026-05-27 16:57:06 -03:00
bors 57d06900fd Auto merge of #157031 - GuillaumeGomez:rollup-FbegncN, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#156970 (coverage: Use original HIR info for synthetic by-move coroutine bodies)
 - rust-lang/rust#157022 (MIR inlining: allow backends to opt-in to inlining intrinsics)
 - rust-lang/rust#157026 (miri subtree update)
 - rust-lang/rust#156390 (Constify Iterator-related methods and functions)
 - rust-lang/rust#156845 (Clarify "infinite size" in cyclic-type diagnostic refers to the type name)
 - rust-lang/rust#156955 (Fix const-eval of shared generic reborrows)
 - rust-lang/rust#156973 (Add uwtable annotation to modules when required)
 - rust-lang/rust#156985 (Limit the additional DLL to Windows)
 - rust-lang/rust#156988 (interpret/validity: properly treat zero-variant enums so that we do not have to check layout.is_uninhabited)
 - rust-lang/rust#157002 (std: Fix thread::available_parallelism on Redox targets)
2026-05-27 19:54:13 +00:00
Aria Givens 1fa9548cb9 Support quotation mark suggestion for attributes in apple tests 2026-05-27 15:37:46 -04:00
Guillaume Gomez 7ade8cceb6 Rollup merge of #157002 - willnode:redox-nproc, r=bjorn3
std: Fix thread::available_parallelism on Redox targets

This brings support to `thread::available_parallelism` on Redox targets via `sysconf`. It has been available since `libc 0.2.177` and tested for months.

References:
- [libc implementation](https://github.com/rust-lang/libc/pull/4728)
- [downstream patch](https://gitlab.redox-os.org/redox-os/rust/-/merge_requests/27)
2026-05-27 20:45:16 +02:00
Guillaume Gomez e8d970b08a Rollup merge of #156988 - RalfJung:validate-uninhabited, r=oli-obk
interpret/validity: properly treat zero-variant enums so that we do not have to check layout.is_uninhabited

I am very happy to finally remove the last of these somewhat ad-hoc checks. :)

r? @oli-obk
2026-05-27 20:45:15 +02:00
Guillaume Gomez 3a37aa5765 Rollup merge of #156985 - mati865:additional-llvm-dll-windows-only, r=jieyouxu
Limit the additional DLL to Windows

rust-lang/rust#156229 didn't limit the additional DLL copy to Windows as it was supposed to.
2026-05-27 20:45:14 +02:00
Guillaume Gomez 0846622465 Rollup merge of #156973 - Darksonn:unwind-tables-module, r=nnethercote
Add uwtable annotation to modules when required

When unwind tables are enabled with `-Cforce-unwind-tables=y`, Rust will annotate all functions with the `uwtable` annotation. However, this annotation is missing on modules, which leads to incorrect unwind tables being generated by LLVM for constructors (such as `asan.module_ctor`).

This was discovered because it leads to a crash in Linux when KASAN and dynamic shadow call stack are both enabled. In this scenario, the kernel uses the unwind tables to locate the `paciasp` and `autiasp` instructions in each function and patches the machine code at boot to use the shadow call stack instructions instead. However, LLVM's AArch64PointerAuth pass emits DWARF info for `paciasp` whenever `-g` is passed, but only emits DWARF info for `autiasp` when the `uwtable` attribute is present. Since the `uwtable` annotation is missing for modules, the relevant directives are generated for only the `autiasp` instruction in `asan.module_ctor`, and not for the `paciasp` instruction. This causes the kernel's dynamic SCS logic to patch the prolouge of `asan.module_ctor`, but not the epilogue. This leads to a crash as the shadow call stack becomes unbalanced.

The fact that LLVM doesn't use the same condition for whether to emit DWARF information for both instructions may be a separate bug in LLVM.

Relevant issue: https://github.com/llvm/llvm-project/issues/188234

AI assistance was used to determine the root cause of this crash from the observed symptoms, and to write the tests. Also thanks to @samitolvanen and @maurer for debugging this issue.

Similar to this previous PR of mine: rust-lang/rust#130824
2026-05-27 20:45:14 +02:00
Guillaume Gomez 3e15f828f6 Rollup merge of #156955 - P8L1:fix-reborrow-promotion-consteval, r=RalfJung
Fix const-eval of shared generic reborrows

`Rvalue::Reborrow` const-eval now handles shared generic reborrows produced by `CoerceShared`. Those reborrows intentionally copy from the source ADT into a distinct same-layout target ADT, so the interpreter uses the transmute-capable copy path for `Mutability::Not`.

Promotion is intentionally kept conservative: promotion candidates whose validated temporary graph contains `Rvalue::Reborrow` are rejected, so generic/user-defined reborrows are not promoted.

Fixes rust-lang/rust#156313.
cc @aapoalas
Tracking: rust-lang/rust#145612
@rustbot label F-reborrow
2026-05-27 20:45:13 +02:00
Guillaume Gomez 66ce7b0106 Rollup merge of #156845 - onehr:clarify-cyclic-type-149842, r=JohnTitor
Clarify "infinite size" in cyclic-type diagnostic refers to the type name

Closes rust-lang/rust#149842

The `TypeError::CyclicTy` diagnostic currently emits
"cyclic type of infinite size". As discussed in the issue, "infinite
size" reads as the in-memory `size_of::<T>()` of values, when it
actually refers to the textual representation of the type name (an
iso-recursive occurs-check failure).

This rewords the message so the qualifier "infinite-size" clearly
modifies the *name*, matching the direction `@fmease`, `@BoxyUwU`,
and the issue author converged on:

```
- cyclic type of infinite size
+ recursive type with infinite-size name
```

Nine existing UI `.stderr` baselines and two `//~ NOTE` annotations
are updated to track the new wording. No semantics change.

Tested:
- ./x test tests/ui/const-generics/occurs-check/ tests/ui/closures/ tests/ui/unboxed-closures/ tests/ui/typeck/ tests/ui/coroutine/ --force-rerun
- ./x test tidy
2026-05-27 20:45:12 +02:00