Skip to content

Conversation

dianne
Copy link
Contributor

@dianne dianne commented Oct 8, 2025

This PR applies various tweaks relating to how the destructors chapter handles static items, const items, and const blocks. In particular:

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Oct 8, 2025
Comment on lines -477 to +493
For a let statement with an initializer, an *extending expression* is an
For a let statement with an initializer, a [static item], a [constant item], or a [const block][const block expression], an *extending expression* is an
expression which is one of the following:

* The initializer expression.
* The initializer expression of a let statement, the body of a static or constant item, or the final expression of a const block.
* The operand of an extending [borrow] expression.
* The [super operands] of an extending [super macro call] expression.
* The operand(s) of an extending [array][array expression], [cast][cast
expression], [braced struct][struct expression], or [tuple][tuple expression]
expression.
* The arguments to an extending [tuple struct] or [tuple enum variant] constructor expression.
* The final expression of an extending [block expression] except for an [async block expression].
* The final expression of an extending [block expression] except for an [async block expression] or const block expression.
Copy link
Contributor Author

@dianne dianne Oct 8, 2025

Choose a reason for hiding this comment

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

This in particular feels awkward to me, but I'm not sure how to make it read better without entirely reworking the format of the list and/or making "extending" a binary relation (mapping expressions to extended scopes). The first bullet point is a base case, which effectively duplicates destructors.scope.lifetime-extension.let (and now destructors.scope.lifetime-extension.static), except without specifying the scope of extended temporaries. This gets a bit messy for const blocks in particular: const blocks are one of the base cases (they extend temporaries to statics) but they also have to be an exception to the grammar for extending expressions (so that we're not also specifying that they extend temporaries to the end of a block when they appear in a let initializer).

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.

2 participants