Skip to content

Add regression test for nested replacement ranges in collect_tokens#159529

Open
UditDewan wants to merge 1 commit into
rust-lang:mainfrom
UditDewan:nested-replacement-ranges-test
Open

Add regression test for nested replacement ranges in collect_tokens#159529
UditDewan wants to merge 1 commit into
rust-lang:mainfrom
UditDewan:nested-replacement-ranges-test

Conversation

@UditDewan

@UditDewan UditDewan commented Jul 18, 2026

Copy link
Copy Markdown

#129346 removed support for nested replacement ranges in collect_tokens, and simplified the nesting out of tests/ui/proc-macro/macro-rules-derive-cfg.rs accordingly. That removal turned out to break real-world code, so it was reverted in #132587 — but the revert only restored the compiler code, not the original nested shape of the test, leaving the nested case uncovered ever since.

This reinstates the nested case as a separate test: the pre-rust-lang/rust#129346 shape of macro-rules-derive-cfg.rs (a cfg_attr expansion nested inside a let statement, nested inside an anonymous constant), combined with the extra inner attributes that #129346 added to the simplified version. If nested replacement range support regresses again, this test fails.

The expected stdout was verified against current nightly; the sibling test's checked-in stdout reproduces byte-for-byte under the same setup.

Closes #132727

PR 129346 removed support for nested replacement ranges and simplified
the nesting out of `macro-rules-derive-cfg.rs` accordingly. The removal
was reverted in PR 132587 because it broke real-world code, but the
revert didn't restore the original nested shape of the test, leaving
the nested case uncovered.

Reinstate the nested case as a separate test, keeping the extra inner
attributes that PR 129346 added to the simplified version of the
original test.
@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 Jul 18, 2026
@rustbot

rustbot commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust Project is excited to review your changes, and you should hear from @nnethercote (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue
Why was this reviewer chosen?

The reviewer was selected based on:

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

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

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a regression test for #132587

3 participants