Commit graph

308866 commits

Author SHA1 Message Date
Esteban Küber
f6938709c8 Point at inner item when using outer item type param
```
error[E0401]: can't use generic parameters from outer item
  --> $DIR/E0401.rs:4:39
   |
LL | fn foo<T>(x: T) {
   |        - type parameter from outer item
LL |     fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) {
   |        ----                           ^ use of generic parameter from outer item
   |        |
   |        generic parameter used in this inner function
   |
help: try introducing a local generic parameter here
   |
LL |     fn bfnr<T, U, V: Baz<U>, W: Fn()>(y: T) {
   |             ++
```
2025-11-01 18:29:46 +00:00
Esteban Küber
973ab7d08f Make "add param to inner item" suggestion verbose
```
error[E0401]: can't use generic parameters from outer item
  --> $DIR/enum-definition-with-outer-generic-parameter-5997.rs:3:16
   |
LL | fn f<Z>() -> bool {
   |      - type parameter from outer item
LL |     enum E { V(Z) }
   |                ^ use of generic parameter from outer item
   |
help: try introducing a local generic parameter here
   |
LL |     enum E<Z> { V(Z) }
   |           +++
```
2025-11-01 18:23:19 +00:00
bors
51f5892019 Auto merge of #148324 - Zalathar:rollup-yp35ktq, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#148165 (Use `mut` less in dataflow analysis)
 - rust-lang/rust#148287 (Fix deferred cast checks using the wrong body for determining constness)
 - rust-lang/rust#148317 (bootstrap: Extract parts of `bootstrap::core::builder` into a `cli_paths` module)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-31 11:43:22 +00:00
Stuart Cook
472c7cd880
Rollup merge of #148317 - Zalathar:cli-paths-mod, r=Kobzol
bootstrap: Extract parts of `bootstrap::core::builder` into a `cli_paths` module

One of the things that makes bootstrap's CLI path handling hard to work with is the fact that it's in the middle of a ~2000 line file full of all sorts of other things. And the primary code sequence is in an unhelpfully-named `StepDescription::run` function.

This PR therefore pulls some key chunks of code out into a `cli_paths` submodule.

This should be a purely non-functional change.
2025-10-31 22:41:20 +11:00
Stuart Cook
43cb58dbb6
Rollup merge of #148287 - oli-obk:push-osluqnunqkyl, r=fee1-dead
Fix deferred cast checks using the wrong body for determining constness

re-introduces https://github.com/rust-lang/rust/pull/103683

it was lost in 4fec845c3f

deferred checks possibly have more such issues, needs investigation.

r? `@fee1-dead`
2025-10-31 22:41:19 +11:00
Stuart Cook
b5c92233fb
Rollup merge of #148165 - nnethercote:less-mut-Analysis, r=cjgillot
Use `mut` less in dataflow analysis

`&mut Analysis` is used a lot:
- In results visitors, even though only one visitor needs mutability.
- In all the `apply_*` methods, even though only one visitor needs mutability.

I've lost track of the number of times I've thought "why are these `mut` again?" and had to look through the code to remind myself. It's really unexpected, and most `Analysis` instances are immutable, because the `state` values are what get mutated.

This commit introduces `RefCell` in one analysis and one results visitor. This then lets another existing `RefCell` be removed, and a ton of `&mut Analysis` arguments become `&Analysis`. And then `Analysis` and `Results` can be recombined.

r? `@cjgillot`
2025-10-31 22:41:18 +11:00
Oli Scherer
8762219b8f Fix deferred cast checks using the wrong body for determining constness 2025-10-31 10:29:54 +00:00
Zalathar
250ee47708 Replace bare tuple with a StepToRun struct 2025-10-31 17:27:33 +11:00
Zalathar
70a9883135 Replace repeated zips with a dedicated StepExtra struct 2025-10-31 17:27:32 +11:00
Zalathar
49205a1dc0 Extract parts of bootstrap::core::builder into a cli_paths module 2025-10-31 16:14:47 +11:00
bors
23c7bad921 Auto merge of #148157 - nnethercote:undo-chain, r=saethlin
Adjust successor iterators.

Because rust-lang/rust#148054 was a slight perf regression.

The problem was seemingly because this iterator structure:
```
slice_iter.chain(Option_iter.chain(Option_iter))
```
changed to this:
```
slice_iter.chain(Option_iter).chain(Option_iter)
```
The commit also tweaks the `slice_iter` part, changing `into_iter` to `iter` and using `[]` instead of `(&[])`, for conciseness and consistency.

r? `@saethlin`
2025-10-31 05:12:24 +00:00
bors
647f1536d2 Auto merge of #148314 - matthiaskrgr:rollup-yo55adr, r=matthiaskrgr
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
0f1db5302f
Rollup merge of #147633 - GuillaumeGomez:bypass-ignore-backends, r=kobzol
Add new `--bypass-ignore-backends` option

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

It adds a new option to `bootstrap` to allow to ignore `//@ ignore-backends` statements in tests.

cc ```@jieyouxu``` ```@antoyo```
r? ```@Kobzol```
2025-10-31 02:39:15 +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
bors
d5419f1e97 Auto merge of #148299 - bjorn3:dummy_backend_check_builds, r=jieyouxu
Allow check builds with binaries for the dummy codegen backend

This is likely the last part necessary for https://github.com/rust-lang/miri/pull/4648. Miri needs to be able to do a regular check build for compile_fail doc tests to work.
2025-10-30 17:36:26 +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
8205e6b75e Auto merge of #148291 - purplesyringa:move-throw-to-unwind, r=bjorn3
Move wasm `throw` intrinsic back to `unwind`

Fixes rust-lang/rust#148246, less invasive than the previously proposed rust-lang/rust#148269. Removes the publicly visible unstable intrinsic tracked in rust-lang/rust#122465 since it's not clear how to export it in a sound manner.

r? `@bjorn3`

---

rustc assumes that regular `extern "Rust"` functions unwind only if the `unwind` panic runtime is linked. `throw` was annotated as such, but unwound unconditionally. This could cause UB when a crate built with `-C panic=abort` called `throw` from `core` built with `-C panic=unwind`, since no terminator was added to handle the panic arising from calling an allegedly non-unwinding `extern "Rust"` function.

rustc was taught to recognize this condition since https://github.com/rust-lang/rust/pull/144225 and prevented such linkage, but this caused regressions in
https://github.com/rust-lang/rust/issues/148246, since this meant that Emscripten projects could not be built with `-C panic=abort` without recompiling std.

The most straightforward solution would be to move `throw` into the `panic_unwind` crate, so that it's only compiled if the panic runtime is guaranteed to be `unwind`, but this is messy due to our architecture. Instead, move it into `unwind::wasm`, which is only compiled for bare-metal targets that default to `panic = "abort"`, rendering the issue moot.
2025-10-30 13:17:11 +00:00
Alisa Sireneva
420544a34a Move wasm throw intrinsic back to unwind
rustc assumes that regular `extern "Rust"` functions unwind only if the
`unwind` panic runtime is linked. `throw` was annotated as such, but
unwound unconditionally. This could cause UB when a crate built with `-C
panic=abort` called `throw` from `core` built with `-C panic=unwind`,
since no terminator was added to handle the panic arising from calling an
allegedly non-unwinding `extern "Rust"` function.

rustc was taught to recognize this condition since
https://github.com/rust-lang/rust/pull/144225 and prevented such
linkage, but this caused regressions in
https://github.com/rust-lang/rust/issues/148246, since this meant that
Emscripten projects could not be built with `-C panic=abort` without
recompiling std.

The most straightforward solution would be to move `throw` into the
`panic_unwind` crate, so that it's only compiled if the panic runtime is
guaranteed to be `unwind`, but this is messy due to our architecture.
Instead, move it into `unwind::wasm`, which is only compiled for
bare-metal targets that default to `panic = "abort"`, rendering the
issue moot.
2025-10-30 15:13:32 +03: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
5538a068bd Show that a test still fails with the feature gate enabled 2025-10-30 09:39:07 +00:00
Oli Scherer
ebb249d69e Fix formatting of const trait aliases 2025-10-30 08:05:37 +00:00
Oli Scherer
a6ca44cf40 Add more tests 2025-10-30 08:05:37 +00:00
Oli Scherer
b9e7cf61be Make const trait aliases work in the old solver 2025-10-30 08:05:37 +00:00
Oli Scherer
bc4d612d46 Prepare test for 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
bors
72fe2ffb39 Auto merge of #148280 - jhpratt:rollup-um01cgu, r=jhpratt
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#138217 (Turn `Cow::is_borrowed,is_owned` into associated functions.)
 - rust-lang/rust#147858 (Micro-optimization attempt in coroutine layout computation)
 - rust-lang/rust#147923 (Simplify rustc_public context handling)
 - rust-lang/rust#148115 (rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`)
 - rust-lang/rust#148137 (Couple of changes for Redox OS)
 - rust-lang/rust#148176 ([rustdoc] Include attribute and derive macros when filtering on "macros")
 - rust-lang/rust#148253 (Handle default features and -Ctarget-features in the dummy backend)
 - rust-lang/rust#148272 (Align VEX V5 boot routine to 4 bytes)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-30 06:55:29 +00: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
645e41abd7
Rollup merge of #148176 - GuillaumeGomez:filter-macros, r=notriddle
[rustdoc] Include attribute and derive macros when filtering on "macros"

As discussed [here](https://github.com/rust-lang/rust/pull/147909), some filters should have been "grouped". This PR allows attribute and derive macros to match the `macro` filter.

I'll wait for https://github.com/rust-lang/rust/pull/148005 to add more tests as it would require a proc-macro library for now.

r? ```@notriddle```
2025-10-30 02:43:45 -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
35fcb55827
Rollup merge of #148115 - fmease:rustdoc-no-capture, r=notriddle
rustdoc: Rename unstable option `--nocapture` to `--no-capture` in accordance with `libtest`

Context: https://github.com/rust-lang/rust/issues/133073, https://github.com/rust-lang/rust/pull/139224 (TL;DR: `libtest` has soft-deprecated `--nocapture` in favor a new & stable `--no-capture`; we should follow suit).

Since the rustdoc flag is unstable (tracking issue: https://github.com/rust-lang/rust/issues/148116), we're allowed to remove the old flag immediately. However since the flag has existed for 4 years we could hard-deprecate the flag first or at least be considerate and provide a diagnostic referring users to the new flag. This PR does neither. Let me know what you would think would be best.

Cargo doesn't use this flag, not yet at least (https://github.com/rust-lang/cargo/pull/9705), so we really are free to sunset this flag without bigger consequences.
2025-10-30 02:43:43 -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
Guillaume Gomez
8cf55ea51c Rename bypass_backends into bypass_ignore_backends 2025-10-29 19:49:24 +01:00
bors
292be5c7c0 Auto merge of #148093 - Azzybana:master, r=nnethercote
perf: removed unnecessary let for return only in layout.rs

perf: removed unnecessary let for return only
2025-10-29 15:37:05 +00: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
Guillaume Gomez
36ac107e3d Add rustc-dev-guide documentation for new --bypass-ignore-backends command line flag 2025-10-29 14:11:07 +01:00