-
Notifications
You must be signed in to change notification settings - Fork 546
specify lifetime extension of pin!
and format_args!
arguments
#1980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Removes an unused trait and impl from the successful tests. - Adds uses following all tests so they test lifetime extension.
@@ -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. |
There was a problem hiding this comment.
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
9adbc21
to
64644b2
Compare
64644b2
to
43c81b3
Compare
6c07751
to
1c9c73c
Compare
1c9c73c
to
53de4ae
Compare
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. |
There was a problem hiding this comment.
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.
Reference PR for rust-lang/rust#145838, given the
format_args!
change in rust-lang/rust#145882. cc @m-ou-seBased on #1979; the first commit is the commit from that PR.