Skip to content
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

Update E0716.md for clarity #120684

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/rustc_error_codes/src/error_codes/E0716.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ let q = p;

Whenever a temporary is created, it is automatically dropped (freed) according
to fixed rules. Ordinarily, the temporary is dropped at the end of the enclosing
statement -- in this case, after the `let`. This is illustrated in the example
above by showing that `tmp` would be freed as we exit the block.
statement -- in this case, after the outer `let` that assigns to `p`. This is
illustrated in the example above by showing that `tmp` would be freed as we exit
the block.
Copy link
Contributor

Choose a reason for hiding this comment

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

There are four lets in this file, two in the first example and two in the second example. I think "after the let" refers to the first let in the first example, but you've updated this as if it's referring to the first let in the second example? Also, you've said "outer let" but there isn't an inner let.

I suggest just changing "after the let" to after the let p` in the first example above". What do you think?

Copy link
Contributor Author

@carschandler carschandler Feb 5, 2024

Choose a reason for hiding this comment

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

So if you count the let tmp = foo(); on line 25 as one then there are five lets, and this one is the "inner let" that I was implying existed, and this is the let that I initially thought the line in question was referring to, but either way, I agree that adding in the "outer" wording is confusing since the second example is really just used to explain what's going on in the first example. I think just making it read:
"after the let p statement"
would be sufficient because then you can refer back to either of the two examples and it's valid.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍


To fix this problem, you need to create a local variable to store the value in
rather than relying on a temporary. For example, you might change the original
Expand Down
Loading