-
Notifications
You must be signed in to change notification settings - Fork 534
Add new temporary lifetime extension rule #1813
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -374,10 +374,10 @@ expression which is one of the following: | |
expression], [braced struct][struct expression], or [tuple][tuple expression] | ||
expression. | ||
* The final expression of any extending [block expression]. | ||
* The arguments to [tuple struct][tuple struct] and [tuple variant][tuple variant] constructors. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We were uncertain about two things here:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think to answer my own question, I do believe the "extending" part is relevant. My understanding is that:
because in function call argument position it is not an "extending expression". The same seems to be true for tuple constructors in rust-lang/rust#140593:
|
||
|
||
So the borrow expressions in `&mut 0`, `(&1, &mut 2)`, and `Some { 0: &mut 3 }` | ||
are all extending expressions. The borrows in `&0 + &1` and `Some(&mut 0)` are | ||
not: the latter is syntactically a function call expression. | ||
So the borrow expressions in `&mut 0`, `(&1, &mut 2)`, and `Some(&mut 3)` | ||
are all extending expressions. The borrows in `&0 + &1` and `f(&mut 0)` are not. | ||
|
||
The operand of any extending borrow expression has its temporary scope | ||
extended. | ||
|
@@ -467,6 +467,8 @@ There is one additional case to be aware of: when a panic reaches a [non-unwindi | |
[struct pattern]: patterns.md#struct-patterns | ||
[tuple pattern]: patterns.md#tuple-patterns | ||
[tuple struct pattern]: patterns.md#tuple-struct-patterns | ||
[tuple struct]: types/struct.md#r-type.struct.tuple | ||
[tuple variant]: types/enum.md#r-type.enum.declaration | ||
Comment on lines
+470
to
+471
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's switch these out for the |
||
|
||
[array expression]: expressions/array-expr.md#array-expressions | ||
[block expression]: expressions/block-expr.md | ||
|
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.