Skip to content

Rollup of 11 pull requests - #163963

Closed
JonathanBrouwer wants to merge 26 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-ziQI4aG
Closed

JonathanBrouwer wants to merge 26 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-ziQI4aG

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

sgasho and others added 26 commits September 19, 2026 16:43
This prevents nonsensical combinations like unsized+on_stack and forces
all users to explicitly handle the difference between sized and unsized
arguments. In a couple of places unsized arguments were handled
incorrectly if they would ever manage to reach that code.
When `TypeVisitable` is implemented but `GenericTypeVisitable` isn't,
the lint (which we'll add soon) recommends adding
`#[derive(GenericTypeVisitable)]`. However, this suggestion is incorrect
for types whose impls ought to be trivial. There, the problem occurs
because the type was added to `TrivialTypeTraversalImpls!` in
`macros.rs`, which added the `TypeVisitable` impl, but wasn't added to
`trivial_impls!` in `generic_visit.rs`, such that the
`GenericTypeVisitable` impl wasn't added.

Imo, the root cause of this problem is that we have two separate macros
for adding trivial impls. So this commit merges them into one, by making
`TrivialTypeTraversalImpls!` add a `GenericTypeVisitable` impl as well.

RE: `Variance`: its `GenericTypeVisitable` impl is now provided by
`TrivialTypeTraversalImpls!`, making the derive unnecessary.

RE: `rustc_hash::FxBuildHasher`: its `GenericTypeVisitable` impl ended
up being removed, because `TypeVisitable` can't be implemented due to it
not implemnting `Debug`. This shouldn't be a problem however, as
`{Generic,}TypeVisitable` should always be implemented in pairs anyway.
I confirmed this by removing the impl from `ra-ap-rustc_type_ir` and
`cargo check`-ing r-a.
The missing impl for arrays was (indirectly) highlighted by the test
suite, the rest -- by the `#[deny]`
This will make it easier to move them in a subsequent commit, since
`UnrollAttr` implements `PartialEq`.

If, in the future, we add more kinds of loop hints, this can become a
small enum wrapping only those attr types.
We should not disable the pattern in MatchBranchSimplification.
The two forms exhaustive match and cast are equivalent, but the cast is better represented in MIR: no branches, only one statement.

AFAIK, LLVM does not handle multiple disjoint intervals well.
As an workaround, the patch emits `assume(ctpop(val) == 1)` to tell LLVM that
the discriminant is a power of two.
Only the `Goto` variant uses `loop_hint_attrs`, so other variants
shouldn't pay the cost. This shrinks `Terminator` and thus
`BasicBlockData` by 8 bytes, and also simplifies many users of
`Terminator`.

Every byte saved from `BasicBlockData` makes a big difference in
max-rss. For aws-sdk-ec2 full check, this saves 34.1 MiB (~0.62% of its
peak RSS)

Add a `TerminatorKind::goto` helper function for convenient construction
with a target and no hints. With that helper available, most of this
commit is simple, straightforward, mechanical translations of
construction or pattern matching. The only notable changes are:

- `compiler/rustc_codegen_ssa/src/mir/block.rs` actually uses the moved hints.
- `compiler/rustc_middle/src/mir/mod.rs` updates the size assertions.
- `compiler/rustc_mir_build/src/builder/cfg.rs` adds/updates helpers.
- `compiler/rustc_mir_build/src/builder/expr/into.rs` has the one place
  that creates a `Goto` with non-empty hints.
… r=saethlin

codegen: tell LLVM that the discriminant is a power of two

Fixes rust-lang#162513.

We should not disable the pattern in MatchBranchSimplification. The two forms exhaustive match and cast are equivalent, but the cast is better represented in MIR: no branches, only one statement.

AFAIK, LLVM does not handle multiple disjoint intervals well. As an workaround, the patch emits `assume(ctpop(val) == 1)` to tell LLVM that the discriminant is a power of two.

LLM disclosure: search the codebase and fix grammer.
… r=beetrees

Split PassMode::IndirectUnsized out of PassMode::Indirect

This prevents nonsensical combinations like unsized+on_stack and forces all users to explicitly handle the difference between sized and unsized arguments. In a couple of places unsized arguments were handled incorrectly if they would ever manage to reach that code.
…n-goto, r=saethlin

Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`

Only the `Goto` variant uses `loop_hint_attrs`, so other variants shouldn't pay the cost. This shrinks `Terminator` and thus `BasicBlockData` by 8 bytes, and also simplifies many users of `Terminator`.

Every byte saved from `BasicBlockData` makes a big difference in max-rss. For aws-sdk-ec2 full check, this saves 34.1 MiB (~0.62% of its peak RSS)

Add a `TerminatorKind::goto` helper function for convenient construction with a target and no hints. With that helper available, most of this commit is simple, straightforward, mechanical translations of construction or pattern matching. The only notable changes are:

- `compiler/rustc_codegen_ssa/src/mir/block.rs` actually uses the moved hints.
- `compiler/rustc_middle/src/mir/mod.rs` updates the size assertions.
- `compiler/rustc_mir_build/src/builder/cfg.rs` adds/updates helpers.
- `compiler/rustc_mir_build/src/builder/expr/into.rs` has the one place that creates a `Goto` with non-empty hints.

---

I have several more potential improvements to basic block sizes, but this one was an easy starting point.
…useZ4

autodiff: fix sysroot candidates in libEnzyme not found error

fix: rust-lang#160335 (comment)

Before

```shell
RUSTFLAGS="-Zautodiff=Enable" cargo +enzyme run
info: `cargo` is unavailable for the active toolchain
info: falling back to "/home/gh-sgasho/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo"
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/gh-sgasho/.rustup/toolchains/enzyme/bin/rustc - --crate-name ___ --print=file-names -Zautodiff=Enable --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit status: 1)
  --- stderr
  error: autodiff backend not found in the sysroot: failed to find a `libEnzyme-23` folder in the sysroot candidates:
         * /home/gh-sgasho/rust-worktrees/enzyme-wrapper-cleanup/build/x86_64-unknown-linux-gnu/stage1/lib
    |
    = note: it will be distributed via rustup in the future
```

After: points out the right candidate dir

```shell
RUSTFLAGS="-Zautodiff=Enable" cargo +enzyme run --release
info: `cargo` is unavailable for the active toolchain
info: falling back to "/home/gh-sgasho/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/cargo"
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/gh-sgasho/.rustup/toolchains/enzyme/bin/rustc - --crate-name ___ --print=file-names -Zautodiff=Enable --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=split-debuginfo --print=crate-name --print=cfg -Wwarnings` (exit status: 1)
  --- stderr
  error: autodiff backend not found in the sysroot: failed to find a `libEnzyme-23.so` in the sysroot candidates:
         * /home/gh-sgasho/rust-worktrees/enzyme-wrapper-cleanup/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib
    |
    = note: it will be distributed via rustup in the future
```

I also verified that sample autodiff code ran successfully using local build, without breaking anything.

r? @ZuseZ4
…le, r=JonathanBrouwer

Add `rustc::missing_generic_type_visitable` lint

Best reviewed commit-by-commit.

The CI will probably complain about the TODOs, but I've added them deliberately, as a way to ask questions.

r? @JonathanBrouwer
cc @rust-lang/rust-analyzer
…Urgau

[rustdoc] Fix more `incoherent_impl` linking

Hopefully last fix for rust-lang#162808.

We force the correct crate to be linked when generating the external location based on the `DefId` crate. I'm actually surprised it wasn't an issue before. Oh well.

r? @Urgau
…r=ZuseZ4

Update Enzyme submodule

r? ZuseZ4
cc @wsmoses

@bors try jobs=dist-x86_64-linux,optional-test-x86_64-gnu-autodiff
Fix debug assert failure in `note_obligation_cause_code_inner`

Applied the recommended fix and turned the crash test into a regression test. Closes rust-lang#139381.

r? lcnr
Use BasicBlock::start_location and Location::START

Construct special MIR locations concisely.
…t, r=lqd

disable next-solver with higher-ranked-assumptions

that's nicer than needing to update all the `[assumptions]` ui tests I think

r? @lqd or @BoxyUwU
…wesleywiser

relax_elf_relocations is x86-only

The flag ends up here

https://github.com/rust-lang/rust/blob/8d1a76430406c877b35d0b627e7f796dcf0dfeca/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp#L393

The LLVM name for this, `X86RelaxRelocations`, makes me believe that this is x86-only. So let's at least document that on our side as well.

Cc @bjorn3  @nikic
@rust-bors rust-bors Bot added the rollup A PR which is a rollup label Oct 8, 2026
@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2026
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels Oct 8, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r+ p=1 force

Trying commonly failed jobs
@bors try jobs=dist-various-1,test-various,test-x86_64-gnu-aux,test-x86_64-msvc-1,test-aarch64-apple-1,test-aarch64-apple-2,test-x86_64-mingw-1,test-i686-msvc,test-armhf-gnu

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e4d5e5c has been approved by JonathanBrouwer

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
Rollup of 11 pull requests


try-job: dist-various-1
try-job: test-various
try-job: test-x86_64-gnu-aux
try-job: test-x86_64-msvc-1
try-job: test-aarch64-apple-1
try-job: test-aarch64-apple-2
try-job: test-x86_64-mingw-1
try-job: test-i686-msvc
try-job: test-armhf-gnu
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-next-trait-solver-polonius failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [ui] tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs#old stdout ----

error in revision `old`: Error: expected failure status (Some(101)) but received status Some(1).
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1/bin/rustc" "/checkout/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage1" "--target=x86_64-unknown-linux-gnu" "--cfg" "old" "--check-cfg" "cfg(test,FALSE,old,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.old" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2015"
stdout: none
--- stderr -------------------------------
error[E0277]: the trait bound `for<'a> u8: From<&'a ()>` is not satisfied
##[error]  --> /checkout/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs:19:15
   |
LL | fn hello() -> impl for<'a> A<'a, Assoc: Into<u8> + 'static + Copy> {
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> From<&'a ()>` is not implemented for `u8`
   |
help: `u8` implements trait `From<T>`
  --> /rustc/FAKE_PREFIX/library/core/src/convert/num.rs:119:8
   |
   = note: `From<bool>`
---
   = note: `From<std::ascii::Char>`
  ::: /rustc/FAKE_PREFIX/library/core/src/ascii/ascii_char.rs:1178:0
   |
   = note: in this macro invocation
   = note: required for `&'a ()` to implement `for<'a> Into<u8>`
   = note: this error originates in the macro `impl_from_bool` which comes from the expansion of the macro `into_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
------------------------------------------

Important

For more information how to resolve CI failures of this job, visit this link.

@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-armhf-gnu failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [ui] tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs#old stdout ----

error in revision `old`: Error: expected failure status (Some(101)) but received status Some(1).
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=arm-unknown-linux-gnueabihf" "--cfg" "old" "--check-cfg" "cfg(test,FALSE,old,next)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.old" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/arm-unknown-linux-gnueabihf/native/rust-test-helpers" "-Clinker=arm-linux-gnueabihf-gcc" "--edition=2015"
stdout: none
--- stderr -------------------------------
error[E0277]: the trait bound `for<'a> u8: From<&'a ()>` is not satisfied
##[error]  --> /checkout/tests/ui/impl-trait/diagnostics/incorrect-skip-binder-for-item-bound.rs:19:15
   |
LL | fn hello() -> impl for<'a> A<'a, Assoc: Into<u8> + 'static + Copy> {
   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> From<&'a ()>` is not implemented for `u8`
   |
help: `u8` implements trait `From<T>`
  --> /rustc/FAKE_PREFIX/library/core/src/convert/num.rs:119:8
   |
   = note: `From<bool>`
---
   = note: `From<std::ascii::Char>`
  ::: /rustc/FAKE_PREFIX/library/core/src/ascii/ascii_char.rs:1178:0
   |
   = note: in this macro invocation
   = note: required for `&'a ()` to implement `for<'a> Into<u8>`
   = note: this error originates in the macro `impl_from_bool` which comes from the expansion of the macro `into_int_impl` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0277`.
------------------------------------------

@jhpratt

jhpratt commented Oct 8, 2026

Copy link
Copy Markdown
Member

This previously failed in #163961; I didn't have time to debug.

@jhpratt jhpratt closed this Oct 8, 2026
@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 8, 2026
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved due to being closed.

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

💔 Test for d9b7b0f failed: CI. Failed jobs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. F-autodiff `#![feature(autodiff)]` rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.