Skip to content

Rollup of 10 pull requests - #163969

Closed
JonathanBrouwer wants to merge 24 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-TNI3CXy
Closed

JonathanBrouwer wants to merge 24 commits into
rust-lang:mainfrom
JonathanBrouwer:rollup-TNI3CXy

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Member

Successful merges:

r? @ghost

Create a similar rollup

sgasho and others added 24 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
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. 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. labels Oct 8, 2026
@rustbot rustbot added the T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. label Oct 8, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member Author

@bors r+ p=5 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 8ccab67 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 10 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-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 8, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #162741 (codegen: tell LLVM that the discriminant is a power of two)
 - #162758 (Split PassMode::IndirectUnsized out of PassMode::Indirect)
 - #163931 (Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`)
 - #163028 (autodiff: fix sysroot candidates in libEnzyme not found error)
 - #163538 (Add `rustc::missing_generic_type_visitable` lint)
 - #163841 ([rustdoc] Fix more `incoherent_impl` linking)
 - #163908 (Update Enzyme submodule)
 - #163935 (Use BasicBlock::start_location and Location::START)
 - #163949 (disable next-solver with higher-ranked-assumptions)
 - #163951 (relax_elf_relocations is x86-only)
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-llvm-22-3 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
error: ui test did not emit an error
note: by default, ui tests are expected not to compile.
hint: use check-pass, build-pass, or run-pass directive to change this behavior.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/rustc" "/checkout/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.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/stage0-sysroot" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--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-fulldeps/internal-lints/missing-generic-type-visitable-derive" "-Znext-solver=coherence" "-A" "unused" "-W" "unused_attributes" "-A" "internal_features" "-A" "incomplete_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "--edition=2015" "-Z" "unstable-options"
stdout: none
--- stderr -------------------------------
warning: unknown lint: `rustc::missing_generic_type_visitable_derive`
##[warning]  --> /checkout/tests/ui-fulldeps/internal-lints/missing-generic-type-visitable-derive.rs:5:9
   |

@rust-bors rust-bors Bot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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

💔 Test for 753332a failed: CI. Failed job:

@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-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2026
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR #163538, which is a member of this rollup, was unapproved.

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 8, 2026
@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: fa122bd (fa122bd8dc757c1d28b38c86e224af991e1e7a88)
Base parent: 36aeef3 (36aeef32c6c012e1af17af53a820aac042846c43)

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 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.