Skip to content

Add regression test for nested replacement ranges in collect_tokens#159529

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
UditDewan:nested-replacement-ranges-test
Jul 20, 2026
Merged

Add regression test for nested replacement ranges in collect_tokens#159529
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
UditDewan:nested-replacement-ranges-test

Conversation

@UditDewan

@UditDewan UditDewan commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

#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

@nnethercote

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@rust-bors

rust-bors Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 5c421f6 has been approved by nnethercote

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 Jul 20, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 20, 2026
…s-test, r=nnethercote

Add regression test for nested replacement ranges in `collect_tokens`

rust-lang#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 rust-lang#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 rust-lang#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 rust-lang#132727
rust-bors Bot pushed a commit that referenced this pull request Jul 20, 2026
…uwer

Rollup of 10 pull requests

Successful merges:

 - #159600 (`rust-analyzer` subtree update)
 - #158046 (proc_macro: preserve file module spans for inner attrs)
 - #159000 (Small cleanups to the incr comp session code)
 - #159449 (Enable single Location to issue multiple borrows)
 - #159587 (Improve `AttrItem::span`)
 - #159460 (Do not mark unnormalized const aliases as rigid when normalizing param env)
 - #159529 (Add regression test for nested replacement ranges in `collect_tokens`)
 - #159585 (Minor `TokenStream` improvements)
 - #159586 (Separate `InterpCx` usage by `ConstAnalysis` phases)
 - #159603 (Clarify `push_stream`/`push_tree`)

Failed merges:

 - #159590 (Remove some dead code)
rust-bors Bot pushed a commit that referenced this pull request Jul 20, 2026
…uwer

Rollup of 18 pull requests

Successful merges:

 - #159600 (`rust-analyzer` subtree update)
 - #158046 (proc_macro: preserve file module spans for inner attrs)
 - #159000 (Small cleanups to the incr comp session code)
 - #159189 (Account for type alias projections in E0308 "expected/found" shortening logic)
 - #159449 (Enable single Location to issue multiple borrows)
 - #159544 (Suggest valid command-line crate names)
 - #159587 (Improve `AttrItem::span`)
 - #159594 (feat(rustc_hir_typeck): suggest `impl Fn` return for capturing closures)
 - #159597 (std: use `arc4random_buf` from libc)
 - #159599 (Resolver: Record at least 1 ambiguous trait if main decl is not a trait.)
 - #158061 (Make `pin!()` more foolproof.)
 - #159460 (Do not mark unnormalized const aliases as rigid when normalizing param env)
 - #159529 (Add regression test for nested replacement ranges in `collect_tokens`)
 - #159571 (Remove unused bundled library lookup for the local crate)
 - #159585 (Minor `TokenStream` improvements)
 - #159586 (Separate `InterpCx` usage by `ConstAnalysis` phases)
 - #159602 (Remove `ItemLike`)
 - #159603 (Clarify `push_stream`/`push_tree`)

Failed merges:

 - #159590 (Remove some dead code)
@rust-bors
rust-bors Bot merged commit ecee943 into rust-lang:main Jul 20, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 20, 2026
rust-timer added a commit that referenced this pull request Jul 20, 2026
Rollup merge of #159529 - UditDewan:nested-replacement-ranges-test, r=nnethercote

Add regression test for nested replacement ranges in `collect_tokens`

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

Development

Successfully merging this pull request may close these issues.

Add a regression test for #132587

3 participants