Closed
Description
There was some confusion in #rust over when values are dropped. It was pointed out that the std::ops::Drop
documentation only says drop is called if "a value goes out of scope", which is inaccurate:
- Scopes apply to variables, not values
- Values can be dropped for other reasons than scopes ending. For example, if a variable is re-assigned, the old value is dropped. There are also temporaries.
I don't know how to best phrase it, but focusing only on scopes is evidently a good way to confuse people.
Metadata
Metadata
Assignees
Labels
Area: Destructors (`Drop`, …)Area: Documentation for any part of the project, including the compiler, standard library, and toolsCategory: An issue proposing an enhancement or a PR with one.Medium priorityRelevant to the language teamRelevant to the library API team, which will review and decide on the PR/issue.