Skip to content

fix: preserve closure receivers for postfix chains - #7013

Open
mgalore wants to merge 1 commit into
rust-lang:mainfrom
mgalore:fix/7011-range-postfix
Open

fix: preserve closure receivers for postfix chains#7013
mgalore wants to merge 1 commit into
rust-lang:mainfrom
mgalore:fix/7011-range-postfix

Conversation

@mgalore

@mgalore mgalore commented Aug 5, 2026

Copy link
Copy Markdown

Summary

  • preserve the closure receiver when formatting field, await, use, and postfix-yield chains after a range
  • add regression coverage for all affected postfix forms

Fixes #7011.

Testing

  • cargo test
  • RUSTFLAGS="-D warnings" cargo test
  • cargo run --bin rustfmt -- --check src/chains.rs
  • git diff --check

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Aug 5, 2026

@ytmimi ytmimi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't just flip this from false to true for all of the variants listed It doesn't apply for ExprKind::Try. Also, as I mentioned in #7011 (comment) we should consider renaming is_method_call_receiver since that doesn't really apply now that we're also using that field for field, await, use, and postfix yield.

View changes since this review

Comment thread src/chains.rs Outdated
Comment on lines +524 to +530
| ast::ExprKind::Yield(ast::YieldKind::Postfix(ref subexpr)) => Some(SubExpr {
expr: Self::convert_try(subexpr, context),
is_method_call_receiver: false,
is_method_call_receiver: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is supposed to apply to ast::ExprKind::Try

@rustbot rustbot added S-waiting-on-author Status: 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 Aug 5, 2026
@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@mgalore
mgalore force-pushed the fix/7011-range-postfix branch from 5f4446c to 688ff00 Compare August 5, 2026 18:06
@mgalore

mgalore commented Aug 5, 2026

Copy link
Copy Markdown
Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: awaiting some action (such as code changes or more information) from the author. labels Aug 5, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Merge .. . tokens producing invalid syntax

3 participants