51056 Commits

Author SHA1 Message Date
bors
647f1536d2 Auto merge of #148314 - matthiaskrgr:rollup-yo55adr, r=matthiaskrgr
Some checks failed
Post merge analysis / analysis (push) Has been cancelled
GHCR image mirroring / DockerHub mirror (push) Has been cancelled
Bump dependencies in Cargo.lock / skip if S-waiting-on-bors (push) Has been cancelled
Bump dependencies in Cargo.lock / update dependencies (push) Has been cancelled
Bump dependencies in Cargo.lock / amend PR (push) Has been cancelled
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#144291 (Constify trait aliases)
 - rust-lang/rust#147633 (Add new `--bypass-ignore-backends` option)
 - rust-lang/rust#148252 (Improve diagnose for unconditional panic when resource limit)
 - rust-lang/rust#148262 (Fix types being marked as dead when they are inferred generic arguments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-31 01:57:02 +00:00
Matthias Krüger
224aab4223 Rollup merge of #148262 - JonathanBrouwer:dead-code-inference, r=nnethercote
Fix types being marked as dead when they are inferred generic arguments

Previously usages of a type in a pattern were ignored. This is incorrect, since if the type is in a pattern we're clearly producing it in the expression we're matching against.

I think this `in_pat` check was meant to be only for variants, which we should indeed ignore since we can just remove the match arm that matches the pattern. Please double check my logic here since this is my first time touching the dead-code pass and I'm not 100% sure this is what the `self.in_pat` check was for.

Fixes https://github.com/rust-lang/rust/issues/148144
2025-10-31 02:39:17 +01:00
Matthias Krüger
d399bc07f3 Rollup merge of #148252 - Binlogo:threads-outrage-diagnose-tips, r=nnethercote
Improve diagnose for unconditional panic when resource limit

Improve diagnostic message for similar issue rust-lang/rust#115021.

When `parallel_compiler=true`, the Rust compiler frontend sets `-Z threads` to match the number of cores, which is reasonable and common. However, in a constrained environment or with an excessive number of cores (such as 377 mentioned below 😑), it could consume all resources and cause a panic.

Setting a default maximum for `-Z threads` in a parallel compiler is challenging. However, the panic error message can guide the user to check the system limit and explicitly lower the thread count according to their needs.

```
14:55:47 thread 'main' panicked at /rustc/f1586001ace26df7cafeb6534eaf76fb2c5513e5/compiler/rustc_interface/src/util.rs:216:18:

14:55:47 called `Result::unwrap()` on an `Err` value: ThreadPoolBuildError { kind: IOError(Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }) }

...

14:55:47 note: compiler flags: --crate-type lib -C opt-level=z -C embed-bitcode=no -C linker=/cache/84996/rust-sdk/target/shim/aarch64-unknown-linux-ohos/clang -Z unstable-options -C symbol-mangling-version=v0 -Z panic-in-drop=abort -C codegen-units=1 -C debuginfo=1 -C embed-bitcode=yes -Z threads=377 -C link-arg=-Wl,--build-id=sha1 -Z binary-dep-depinfo
```
2025-10-31 02:39:16 +01:00
Matthias Krüger
149ad71e05 Rollup merge of #144291 - oli-obk:const_trait_alias, r=fee1-dead
Constify trait aliases

Allow `const trait Foo = Bar + [const] Baz;` trait alias declarations. Their rules are the same as with super traits of const traits. So `[const] Baz` or `const Baz` is only required for `[const] Foo` or `const Foo` bounds respectively.

tracking issue rust-lang/rust#41517 (part of the general trait alias feature gate, but I can split it out into a separate const trait alias feature gate. I just assumed that const traits would stabilize before trait aliases, and we'd want to stabilize trait aliases together with const trait aliases at the same time)

r? ``@compiler-errors`` ``@fee1-dead``
2025-10-31 02:39:14 +01:00
bors
ab4960e680 Auto merge of #148298 - jieyouxu:revert-cc, r=madsmtm
Revert "Auto merge of #146186 - dpaoliello:cc, r=jieyouxu"

This reverts https://github.com/rust-lang/rust/pull/146186. This will mean regressing whichever `cc` fixes were needed for

> fixes when compiling the Rust compiler for Arm64EC.

It's not clear which `cc` change causes the across-the-board perf regression, I suspect it's a change in how certain compiler flags are handed. But I can immediately tell this is a rabbit hole to investigate, so let's revert for now to return-to-baseline and alleviate time pressure.
2025-10-30 22:47:42 +00:00
bjorn3
4b9dc49975 Allow check builds with binaries for the dummy codegen backend 2025-10-30 15:13:05 +00:00
Jieyou Xu
2b9b7bb3d4 Revert "Auto merge of #146186 - dpaoliello:cc, r=jieyouxu"
This reverts commit bc1d7273df, reversing
changes made to c9537a94a6.
2025-10-30 22:46:35 +08:00
bors
6906167e01 Auto merge of #148193 - camsteffen:remove-qpath-langitem, r=cjgillot
Remove `QPath::LangItem`

Closes rust-lang/rust#115178.

r? cjgillot
2025-10-30 10:04:21 +00:00
Oli Scherer
b9e7cf61be Make const trait aliases work in the old solver 2025-10-30 08:05:37 +00:00
Oli Scherer
544a5a3e0e Make const trait aliases work in next solver 2025-10-30 08:05:37 +00:00
Oli Scherer
8b122f1e11 Generate const predicates for const trait aliases 2025-10-30 08:05:37 +00:00
Oli Scherer
5f6772c2a7 Constify trait aliases 2025-10-30 08:05:37 +00:00
Jonathan Brouwer
a09c4fc862 Fix types being marked as dead when they are inferred generic arguments
Signed-off-by: Jonathan Brouwer <jonathantbrouwer@gmail.com>
2025-10-30 08:31:07 +01:00
Jacob Pratt
4796814045 Rollup merge of #148272 - vexide:fix/linker-script-align, r=saethlin
Align VEX V5 boot routine to 4 bytes

This PR fixes an alignment issue with the initialization routine on the VEX V5 target.

Previously, if the `.text` output section contained any functions aligned to more than four bytes, the linker would add padding bytes before the beginning of `.text` rather than changing the position of the aligned function inside the section itself. This is an issue because the entry point for the program needs to be located at `0x3800_0020` on this platform and the addition of padding could cause it to be moved.

To fix this, I've forced the start address of the `.text` section to be aligned to 4 bytes so that the entry point is placed consistently. Items inside the section can still be aligned to values larger than this.
2025-10-30 02:43:46 -04:00
Jacob Pratt
f76239ce1f Rollup merge of #148253 - bjorn3:dummy_backend_target_features, r=JonathanBrouwer
Handle default features and -Ctarget-features in the dummy backend

This prevents a warning about ABI relevant target features not being set on x86 and arm. In addition it is required for miri to report correct features in is_*_feature_detected!() if miri switches to the dummy backend.

Required for https://github.com/rust-lang/miri/pull/4648
2025-10-30 02:43:46 -04:00
Jacob Pratt
a7491882e5 Rollup merge of #148137 - bjorn3:redox_fixes, r=mati865
Couple of changes for Redox OS

This upstreams all redox patches that can be upstreamed.

cc ```@jackpot51```
2025-10-30 02:43:44 -04:00
Jacob Pratt
2e4e4abf44 Rollup merge of #147923 - celinval:rpub-remove-trait, r=oli-obk
Simplify rustc_public context handling

We no longer need two thread-local variables to store the context. We used to have two because the conversion logic used to live in a separate crate from the rest of the business logic.

I'm also merging the Container struct and the CompilerInterface trait as a single struct. This removes the unnecessary indirection and code duplication. Using a trait would also block us from adding any generic method to the compiler interface.

r? ``@oli-obk``

cc: ``@makai410``
2025-10-30 02:43:42 -04:00
Jacob Pratt
1ae00ba888 Rollup merge of #147858 - yotamofek:pr/mir/coroutine-layout-opt, r=cjgillot
Micro-optimization attempt in coroutine layout computation

In `compute_layout`, there were a bunch of collections (`IndexVec`s) that were being created by `push`ing in a loop, instead of a, hopefully, more performant usage of iterator combinators. [Second commit](6f682c2774) is just a small cleanup.

I'd love a perf run to see if this shows up in benchmarks.
2025-10-30 02:43:42 -04:00
Jacob Pratt
f1a0dfd145 Rollup merge of #138217 - theemathas:cow_is_owned_borrowed_associated, r=dtolnay
Turn `Cow::is_borrowed,is_owned` into associated functions.

This is done because `Cow` implements `Deref`. Therefore, to avoid conflicts with an inner type having a method of the same name, we use an associated method, like `Box::into_raw`.

Tracking issue: #65143
2025-10-30 02:43:41 -04:00
Celina G. Val
e0b8dd38bc Simplify rustc_public context handling
We no longer need two thread-local variables to store the context.
We used to have two because the conversion logic used to live in a
separate crate from the rest of the business logic.

I'm also removing the Container struct and replacing the
CompilerInterface trait with a struct. This removes the unnecessary
indirection and code duplication. Using a trait would also block us
from adding any generic method to the compiler interface.
2025-10-29 23:31:50 +00:00
Lewis McClelland
958d0a3836 Align VEX V5 boot routine to 4 bytes 2025-10-29 17:52:05 -04:00
bjorn3
4d7c784caf Handle default features and -Ctarget-features in the dummy backend
This prevents a warning about ABI relevant target features not being set
on x86 and arm. In addition it is required for miri to report correct
features in is_*_feature_detected!() if miri switches to the dummy backend.
2025-10-29 13:43:14 +00:00
Binlogo
5aa2a90724 Improve diagnose for unconditional panic when resource limit 2025-10-29 21:21:25 +08:00
bjorn3
fa0f1630d6 Add riscv64gc-unknown-redox
Co-Authored-By: Jeremy Soller <jackpot51@gmail.com>
2025-10-29 13:15:12 +00:00
Jeremy Soller
bd61985bb6 Disable crt_static_allows_dylibs in redox targets 2025-10-29 13:14:54 +00:00
Matthias Krüger
dfaaa1bb7f Rollup merge of #148226 - cuviper:bootstrap-update, r=Mark-Simulacrum
Bootstrap update

- Update CURRENT_RUSTC_VERSION post-bump
- Bump stage0 to 1.92.0-beta.1
- Update `#[cfg(bootstrap)]`
2025-10-29 08:07:51 +01:00
Matthias Krüger
9489751d80 Rollup merge of #148131 - tmiasko:deduce-spread-arg, r=wesleywiser
Skip parameter attribute deduction for MIR with `spread_arg`

When a MIR argument is spread at ABI level, deduced attributes are potentially misapplied, since a spread argument can correspond to zero or more arguments at ABI level.

Disable deduction for MIR using spread argument for the time being.
2025-10-29 08:07:50 +01:00
Matthias Krüger
8da95ac135 Rollup merge of #147281 - fee1-dead-contrib:clarify-binop-diag, r=jackh726
Make diagnostics clearer for binop-related errors in foreign crates

Fixes redundant language and bad grammar.
2025-10-29 08:07:49 +01:00
Matthias Krüger
4602127362 Rollup merge of #144444 - dawidl022:contracts/variable-scoping-rebased, r=jackh726
Contract variable declarations

This change adds contract variables that can be declared in the `requires` clause and can be referenced both in `requires` and `ensures`, subject to usual borrow checking rules. This allows any setup common to both the `requires` and `ensures` clauses to only be done once.

In particular, one future use case would be for [Fulminate](https://dl.acm.org/doi/10.1145/3704879)-like ownership assertions in contracts, that are essentially side-effects, and executing them twice would alter the semantics of the contract.

As of this change, `requires` can now be an arbitrary sequence of statements, with the final expression being of type `bool`. They are executed in sequence as expected, before checking if the final `bool` expression holds.

This PR depends on rust-lang/rust#144438 (which has now been merged).

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

**Other changes introduced**:
- Contract macros now wrap the content in braces to produce blocks, meaning there's no need to wrap the content in `{}` when using multiple statements. The change is backwards compatible, in that wrapping the content in `{}` still works as before. The macros also now treat `requires` and `ensures` uniformally, meaning the `requires` closure is built inside the parser, as opposed to in the macro.

**Known limiatations**:
- Contracts with variable declarations are subject to the regular borrow checking rules, and the way contracts are currently lowered limits the usefulness of contract variable declarations. Consider the below example:

  ```rust
  #[requires(let init_x = *x; true)]
  #[ensures(move |_| *x == 2 * init_x)]
  fn double_in_place(x: &mut i32) {
      *x *= 2;
  }
  ```

  We have used the new variable declarations feature to remember the initial value pointed to by `x`, however, moving `x` into the `ensures` does not pass the borrow checker, meaning the above function contract is illegal. Ideally, something like the above should be expressable in contracts.
2025-10-29 08:07:49 +01:00
bors
907705abea Auto merge of #148208 - camsteffen:assign-desugar-span, r=wesleywiser
Remove unused `AssignDesugar` span
2025-10-29 01:59:52 +00:00
bors
044d68c3cb Auto merge of #148182 - saethlin:trivial-consts-recursive, r=eholk
Accept trivial consts based on trivial consts

This is an expansion of https://github.com/rust-lang/rust/pull/148040.

The previous implementation only accepted trivial consts that assign a literal. For example:
```rust
const A: usize = 0;
const B: usize = A;
```
Before this PR, only `A` was a trivial const. Now `B` is too.
2025-10-28 22:52:08 +00:00
Tomasz Miąsko
e9252a42f5 Skip parameter attribute deduction for MIR with spread_arg
When a MIR argument is spread at ABI level, deduced attributes are
potentially misapplied, since a spread argument can correspond to zero
or more arguments at ABI level.

Disable deduction for MIR using spread argument for the time being.
2025-10-28 23:07:04 +01:00
Josh Stone
8fd2dc0034 Update #[cfg(bootstrap)] 2025-10-28 13:35:43 -07:00
Josh Stone
f25ca45fd1 Update CURRENT_RUSTC_VERSION post-bump
(cherry picked from commit 813072186c1c305ea62c7270f1514dfab5166af2)
2025-10-28 13:22:00 -07:00
Matthias Krüger
6a7bcec8da Rollup merge of #148177 - bjorn3:codegen_backend_crate_types, r=WaffleLapkin
Allow codegen backends to indicate which crate types they support

This way cargo will drop the unsupported crate types for crates that
specify multiple crate types.

This is a prerequisite for https://github.com/rust-lang/miri/pull/4648.
2025-10-28 17:49:29 +01:00
Matthias Krüger
1fe148371a Rollup merge of #148173 - tiif:fix-opaque-ice, r=BoxyUwU
Emit delayed bug during wfck for stranded opaque

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/235

## Problem

The fundamental issue here is ``OpaqueTypeCollector`` operates on ``rustc_middle::Ty``, but ``check_type_wf`` operates on HIR.

Since [check_type_wf](2f7620a5cc/compiler/rustc_hir_analysis/src/check/wfcheck.rs (L2262)) operates on HIR, it can see the stranded opaque and tries to infer it's hidden type. But ``OpaqueTypeCollector`` operates on ``rustc_middle::Ty``, so the ``OpaqueTypeCollector`` can no longer see a stranded opaque, hence its hidden type could not be inferred.

As a result, the tests ICE'ed at 34a8c7368c/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs (L253)

## Proposed solution

This PR detects stranded opaque types during wf check and emit a delayed bug for it.

## Alternative solution

`@BoxyUwU` and I had considered rewriting ``OpaqueTypeCollector`` to be a HIR visitor instead of a ``rustc_middle::Ty`` visitor, but we believe a HIR-based ``OpaqueTypeCollector`` will not work and might not worth the cost of rewriting.

## Acknowledgement

This PR is a joint effort with `@BoxyUwU` :3
2025-10-28 17:49:29 +01:00
Cameron Steffen
a45c6dd2c0 Remove AssignDesugar span 2025-10-28 11:18:58 -05:00
bjorn3
9fc1378916 Report correct unsupported crate type for the dummy codegen backend 2025-10-28 14:26:01 +00:00
bors
bc1d7273df Auto merge of #146186 - dpaoliello:cc, r=jieyouxu
Update cc-rs to 1.2.39

For my purposes, contains fixes when compiling the Rust compiler for Arm64EC.

Checked the commits since 1.2.16, and I don't see anything else that may affect Rust?

`find-msvc-tools` was also factored out from `cc` to allow updating the use in `rustc_codegen_ssa` (finding the linker when running the Rust compiler) to be separate from the use in `rustc_llvm` (building LLVM as part of the Rust compiler).
2025-10-28 13:25:45 +00:00
tiif
c797724ed5 Add delayed bug for stranded opaque 2025-10-28 13:02:24 +00:00
Oli Scherer
3ca752f979 Trait aliases are rare large ast nodes, box them 2025-10-28 11:11:56 +00:00
Stuart Cook
ff7909bc21 Rollup merge of #148175 - osamakader:fix-typos-duplicate-words, r=lcnr
Fix typos: duplicate words in comments

- Fix 'the the' → 'the' in rustc_const_eval
- Fix 'wether' → 'whether' in compiletest
- Fix 'is is' → 'is' in rustc_ast_pretty (2 instances)
2025-10-28 20:39:40 +11:00
Stuart Cook
a383fe8f20 Rollup merge of #148139 - Urgau:add-coverage-scope, r=Zalathar
Add `coverage` scope for controlling paths in code coverage

This PR adds a `coverage` scope (for `-Zremap-path-scope`) for controlling if the paths that ends up in code coverage output should be remapped or not.

Currently code coverage use the `macro` scope which is not a appropriate scope for them.

Found during the stabilization of `-Zremap-path-scope` https://github.com/rust-lang/rust/pull/147611#issuecomment-3396210043 and was asked to be in a separate PR in https://github.com/rust-lang/rust/pull/147611#issuecomment-3448455252.

r? compiler
2025-10-28 20:39:37 +11:00
Stuart Cook
1cf3dc6b5a Rollup merge of #147840 - jdonszelmann:unsizing-coercions, r=lcnr
Rework unsizing coercions in the new solver

Replaces https://github.com/rust-lang/rust/pull/141926, contains:

- a commit adding tests that fail before this work
- the two commits from the previous PR
- a commit in which these tests are fixed
- finally, a fixup for an in my opinion rather large regression in diagnostics. It's still not perfect, but better?

I hope this is roughly what you had in mind

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/241 and https://github.com/rust-lang/trait-system-refactor-initiative/issues/238, adding tests for both

r? ````@lcnr````
2025-10-28 20:39:33 +11:00
Stuart Cook
ef8003bbb9 Rollup merge of #147185 - RalfJung:repr-c-not-zst, r=petrochenkov
repr(transparent): do not consider repr(C) types to be 1-ZST

Context: https://github.com/rust-lang/unsafe-code-guidelines/issues/552

This experiments with a [suggestion](https://github.com/rust-lang/rfcs/pull/3845#discussion_r2388463698) by ```@RustyYato``` to stop considering repr(C) types as 1-ZST for the purpose of repr(transparent). If we go with https://github.com/rust-lang/rfcs/pull/3845 (or another approach for fixing repr(C)), they will anyway not be ZST on all targets any more, so this removes a portability hazard. Furthermore, zero-sized repr(C) structs [may have to be treated](https://github.com/rust-lang/unsafe-code-guidelines/issues/552#issuecomment-3250657813) as non-ZST for the win64 ABI (at least that's what gcc/clang do), so allowing them to be ignored in repr(transparent) types is not entirely coherent.

Turns out we already have an FCW for repr(transparent), namely https://github.com/rust-lang/rust/issues/78586. This extends that lint to also check for repr(C).
2025-10-28 20:39:32 +11:00
Stuart Cook
68618a8f92 Rollup merge of #144936 - rcvalle:rust-cfi-fix-144641, r=lcnr
CFI: Fix types that implement Fn, FnMut, or FnOnce

When looking for instances which could either be dynamically called through a vtable or through a concrete trait method, we missed `FnPtrShim`, instead only looking at `Item` and closure-likes. Fixes rust-lang/rust#144641.

cc ```@1c3t3a``` ```@Jakob-Koschel```
2025-10-28 20:39:32 +11:00
bors
df984edf44 Auto merge of #147083 - dianne:non-extended-indices, r=matthewjasper
Do not lifetime-extend array/slice indices

When lowering non-overloaded indexing operations to MIR, this uses the temporary lifetime of the index expression for the index temporary, rather than applying the temporary lifetime of the indexing operation as a whole to the index.

For example, in
```rust
let x = &xs[i];
```
previously, the temporary containing the result of evaluating `i` would live until the end of the block due to the indexing operation being [lifetime-extended](https://doc.rust-lang.org/nightly/reference/destructors.html#temporary-lifetime-extension). Under this PR, the index temporary only lives to the end of the `let` statement because it uses the more precise temporary lifetime of the index expression.

I don't think this will affect semantics in an observable way, but the more precise `StorageDead` placement may slightly improve analysis/codegen performance.

r? mir
2025-10-28 03:02:00 +00:00
Cameron Steffen
95732f42cd Fix a bad hint 2025-10-27 21:19:38 -05:00
Cameron Steffen
bef018eae3 Mark yield spans with desugaring 2025-10-27 21:19:38 -05:00
Cameron Steffen
ead5e120a5 Remove QPath::LangItem 2025-10-27 21:19:38 -05:00