Skip to content

autodiff: don't ICE on invalid macro arguments - #166196

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
puranikyashaswin:autodiff-invalid-args
Nov 26, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
puranikyashaswin:autodiff-invalid-args

Conversation

@puranikyashaswin

@puranikyashaswin puranikyashaswin commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #150326
Fixes #150327
Fixes #150329
Fixes #160329

The generated function name must now be a single identifier. Activities that aren't identifiers get the existing "did not recognize Activity" error. A function with a return type but no activities gets the existing activity count error, and expansion stops there.

In #160329, parser recovery leaves the function with more parameters than activities. That case now stops at the count error, so its crash test moves to tests/ui/autodiff.

@rustbot

rustbot commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in compiler/rustc_builtin_macros/src/autodiff.rs

cc @ZuseZ4

@rustbot rustbot added 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. labels Nov 19, 2026
@rustbot

rustbot commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project has assigned @tmiasko (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks.

Please see the contribution instructions and our LLM policy for more information.

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 79 candidates
  • Random selection from 20 candidates

@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@tmiasko

tmiasko commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

r? ZuseZ4

@rustbot rustbot assigned ZuseZ4 and unassigned tmiasko Nov 19, 2026
@rust-bors

This comment has been minimized.

@ZuseZ4

ZuseZ4 commented Nov 25, 2026

Copy link
Copy Markdown
Member

Thank you, while reviewing this PR I noticed two issues that I quickly fixed last night. If you can rebase onto the latest main and force-push, then I can have another look at this PR

@rustbot

rustbot commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@puranikyashaswin

Copy link
Copy Markdown
Contributor Author

@ZuseZ4 Rebased onto the latest main. Thanks for taking a look.

@ZuseZ4

ZuseZ4 commented Nov 25, 2026

Copy link
Copy Markdown
Member

Thanks. The tests/ui/autodiff/invalid-signature-recovery.rs error is still misleading, but it already throws another valuable error and it doesn't panic so that's good enough.

In general, the code tries to emit as many errors at once as possible (to shorten debug cycles), but if the count mismatches, we cannot reliably match activities to arguments to begin with, so it seems sensible to error earlier.

@bors r+ rollup

@rust-bors

rust-bors Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b5d04d2 has been tentatively approved by ZuseZ4

It will be put into the queue for this repository once PR CI succeeds.

@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 Nov 25, 2026
clarfonthey added a commit to clarfonthey/rust that referenced this pull request Nov 26, 2026
…args, r=ZuseZ4

autodiff: don't ICE on invalid macro arguments

Fixes rust-lang#150326
Fixes rust-lang#150327
Fixes rust-lang#150329
Fixes rust-lang#160329

The generated function name must now be a single identifier. Activities that aren't identifiers get the existing "did not recognize Activity" error. A function with a return type but no activities gets the existing activity count error, and expansion stops there.

In rust-lang#160329, parser recovery leaves the function with more parameters than activities. That case now stops at the count error, so its crash test moves to `tests/ui/autodiff`.
clarfonthey added a commit to clarfonthey/rust that referenced this pull request Nov 26, 2026
…args, r=ZuseZ4

autodiff: don't ICE on invalid macro arguments

Fixes rust-lang#150326
Fixes rust-lang#150327
Fixes rust-lang#150329
Fixes rust-lang#160329

The generated function name must now be a single identifier. Activities that aren't identifiers get the existing "did not recognize Activity" error. A function with a return type but no activities gets the existing activity count error, and expansion stops there.

In rust-lang#160329, parser recovery leaves the function with more parameters than activities. That case now stops at the count error, so its crash test moves to `tests/ui/autodiff`.
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
Rollup of 4 pull requests

Successful merges:

 - #166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - #165651 (compiletest: Further clean up directive parsing)
 - #166196 (autodiff: don't ICE on invalid macro arguments)
 - #166556 (remove `Box::into_boxed_slice`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 26, 2026
…args, r=ZuseZ4

autodiff: don't ICE on invalid macro arguments

Fixes rust-lang#150326
Fixes rust-lang#150327
Fixes rust-lang#150329
Fixes rust-lang#160329

The generated function name must now be a single identifier. Activities that aren't identifiers get the existing "did not recognize Activity" error. A function with a return type but no activities gets the existing activity count error, and expansion stops there.

In rust-lang#160329, parser recovery leaves the function with more parameters than activities. That case now stops at the count error, so its crash test moves to `tests/ui/autodiff`.
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #164252 (Share retain implementation between Vec and VecDeque)
 - #166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - #166506 (traits: Fix dead match arm for String type suggestions.)
 - #164542 (Add regression test for #151312)
 - #165651 (compiletest: Further clean up directive parsing)
 - #166196 (autodiff: don't ICE on invalid macro arguments)
 - #166556 (remove `Box::into_boxed_slice`)
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #164252 (Share retain implementation between Vec and VecDeque)
 - #166008 (fix inconsistent precedence of -Ctarget-feature wrt -Zllvm-target-feature)
 - #166156 (tests: cover proc-macro metadata path remapping)
 - #166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - #166506 (traits: Fix dead match arm for String type suggestions.)
 - #164542 (Add regression test for #151312)
 - #165651 (compiletest: Further clean up directive parsing)
 - #166196 (autodiff: don't ICE on invalid macro arguments)
 - #166556 (remove `Box::into_boxed_slice`)
 - #166562 (docs: add backticks around `!` in primitive docs )
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #164252 (Share retain implementation between Vec and VecDeque)
 - #166008 (fix inconsistent precedence of -Ctarget-feature wrt -Zllvm-target-feature)
 - #166156 (tests: cover proc-macro metadata path remapping)
 - #166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - #166506 (traits: Fix dead match arm for String type suggestions.)
 - #164542 (Add regression test for #151312)
 - #165651 (compiletest: Further clean up directive parsing)
 - #166196 (autodiff: don't ICE on invalid macro arguments)
 - #166556 (remove `Box::into_boxed_slice`)
 - #166562 (docs: add backticks around `!` in primitive docs )
@rust-bors
rust-bors Bot merged commit c18385b into rust-lang:main Nov 26, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 26, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
Rollup merge of #166196 - puranikyashaswin:autodiff-invalid-args, r=ZuseZ4

autodiff: don't ICE on invalid macro arguments

Fixes #150326
Fixes #150327
Fixes #150329
Fixes #160329

The generated function name must now be a single identifier. Activities that aren't identifiers get the existing "did not recognize Activity" error. A function with a return type but no activities gets the existing activity count error, and expansion stops there.

In #160329, parser recovery leaves the function with more parameters than activities. That case now stops at the count error, so its crash test moves to `tests/ui/autodiff`.
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 27, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#164252 (Share retain implementation between Vec and VecDeque)
 - rust-lang/rust#166008 (fix inconsistent precedence of -Ctarget-feature wrt -Zllvm-target-feature)
 - rust-lang/rust#166156 (tests: cover proc-macro metadata path remapping)
 - rust-lang/rust#166171 (borrowck: Fix Reborrow ICE on types with several lifetimes)
 - rust-lang/rust#166506 (traits: Fix dead match arm for String type suggestions.)
 - rust-lang/rust#164542 (Add regression test for rust-lang/rust#151312)
 - rust-lang/rust#165651 (compiletest: Further clean up directive parsing)
 - rust-lang/rust#166196 (autodiff: don't ICE on invalid macro arguments)
 - rust-lang/rust#166556 (remove `Box::into_boxed_slice`)
 - rust-lang/rust#166562 (docs: add backticks around `!` in primitive docs )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

5 participants