Skip to content

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented May 7, 2025

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label May 7, 2025
@m-ou-se
Copy link
Member Author

m-ou-se commented May 7, 2025

@WaffleLapkin I vaguely remember you were working on rewriting this section at some point? Maybe I misremember.

@WaffleLapkin
Copy link
Member

I indeed found this message:

[14:11] waffle: thank uuu!! with this knowledge I can document this stuff in the compiler and reference >:3

I did forget about it and can't find any changes I did back then, so I'd assume I haven't even started rewriting it. I'll write this down so I don't forget again ^^'

@joshtriplett
Copy link
Member

This looks correct to me.

Comment on lines +470 to +471
[tuple struct]: types/struct.md#r-type.struct.tuple
[tuple variant]: types/enum.md#r-type.enum.declaration
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's switch these out for the r identifiers.

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* The arguments to [tuple struct][tuple struct] and [tuple variant][tuple variant] constructors.
* The arguments to [tuple struct] and [tuple variant] constructors.

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

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

It looks like the examples below still need updating (just below in the "Examples" section).

@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

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

We were uncertain about two things here:

  • What is an "extending ... expression"? Does that mean it is a subexpression of something else that is extending?
  • Related to that, do these need the adjective "extending"? That is, "extending tuple struct" and "extending tuple variant"? If so, would it make sense to merge this with the third bullet point, or at least to move this bullet point to be next to it?

Copy link
Contributor

@ehuss ehuss May 8, 2025

Choose a reason for hiding this comment

The 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:

  • Some{0: &temp()} — ok
  • (Some{0: &temp()},) — ok
  • foo(Some{0: &temp()},) — ERROR

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:

  • Some(&temp()) — ok
  • (Some(&temp()),) — ok
  • foo(Some(&temp()),) — ERROR

@ehuss ehuss added S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author. and removed S-waiting-on-review Status: The marked PR is awaiting review from a maintainer labels May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: The marked PR is awaiting some action (such as code changes) from the PR author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants