Skip to content

Conversation

dianne
Copy link
Contributor

@dianne dianne commented Aug 26, 2025

Reference PR for rust-lang/rust#145838, given the format_args! change in rust-lang/rust#145882. cc @m-ou-se

Based on #1979; the first commit is the commit from that PR.

- Removes an unused trait and impl from the successful tests.
- Adds uses following all tests so they test lifetime extension.
@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Aug 26, 2025
@@ -434,6 +434,7 @@ expression which is one of the following:
expression], [braced struct][struct expression], or [tuple][tuple expression]
expression.
* The arguments to an extending [tuple struct] or [tuple variant] constructor expression.
* The argument(s) to an extending [`pin!`] or [`format_args!`] [macro invocation] expression.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ideally this should be clearer about the format arguments being extended, not the format string (which doesn't need extension), but I've had trouble including that detail without breaking the flow/clarity of the section

@dianne dianne force-pushed the extending-macros branch 2 times, most recently from 6c07751 to 1c9c73c Compare August 28, 2025 05:41
Comment on lines +444 to +450
r[destructors.scope.lifetime-extension.exprs.borrow]
The operand of any extending borrow expression has its temporary scope
extended.

r[destructors.scope.lifetime-extension.exprs.macros]
The built-in macros [`pin!`] and [`format_args!`] create temporaries.
Any extending [`pin!`] or [`format_args!`] [macro invocation] expression has an extended temporary scope.
Copy link
Contributor Author

@dianne dianne Aug 28, 2025

Choose a reason for hiding this comment

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

Fourth pass: I've broken up destructors.scope.lifetime-extension.exprs to match destructors.scope.lifetime-extension.patterns and to put the rule for built-in macros' temporaries in a subsection. I've also moved the rule for arguments' extension back into the the newly-delimited rule destructors.scope.lifetime-extension.exprs.extending. I'm not satisfied with the wording yet, but structurally I think it's an improvement.

I'm doing a bit of conflation here. The "temporaries" here are both:

  • super let bindings; since they have (extended) temporary scopes, I feel like referring to them as "temporaries" is most fitting for the moment.
  • The borrowed temporaries created when a value expression is passed to format_args!.

Let me know if it needs further clarification. My hope is that it's a suitable level of detail for how these macros behave, to avoid specifying their exact expansion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: The marked PR is awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants