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

Document guarantees around drop and panicing #50765

Closed
RalfJung opened this issue May 15, 2018 · 3 comments
Closed

Document guarantees around drop and panicing #50765

RalfJung opened this issue May 15, 2018 · 3 comments
Labels
A-destructors Area: Destructors (`Drop`, …) A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

Currently, when a panic occurs during a regular (i.e., non-unwinding) drop of a local variable, the remaining local variables are still going to have their drop called as usual: https://play.rust-lang.org/?gist=1e2b47513bbfebb71cb6d4e05eca822d&version=stable&mode=debug

Furthermore, if a panic occurs during the drop of a struct with members, the member's drop is also still going to be executed: https://play.rust-lang.org/?gist=69c5e0e922f96dbdc939dad6453ecc6c&version=stable&mode=debug

It would be nice to have such guarantees spelled out explicitly somewhere. Given that this is externally visible behavior, it is probably covered by the stability guarantee, but still -- these guarantees will be really important for providing safe stack pinning APIs.

I am not sure what would be a good place for this to be documented, maybe somewhere in https://doc.rust-lang.org/stable/reference/?

Cc @pythonesque

@petrochenkov
Copy link
Contributor

petrochenkov commented May 15, 2018

IIRC, panics in destructors and double panics were very buggy, so the precise rules weren't de jure stabilized and were expected to change in some ways.
The "language semver" RFC (https://github.com/rust-lang/rfcs/blob/master/text/1122-language-semver.md) even mentions this case specifically.
I don't know what is the status today, perhaps migration to MIR changed something, perhaps not.

@kennytm kennytm added A-destructors Area: Destructors (`Drop`, …) T-lang Relevant to the language team, which will review and decide on the PR/issue. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. labels May 15, 2018
@steveklabnik
Copy link
Member

Yes; this issue should be opened on the reference. Would you mind moving this over there? Thanks! https://github.com/rust-lang-nursery/reference/issues/new

@RalfJung
Copy link
Member Author

Done: rust-lang/reference#348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-destructors Area: Destructors (`Drop`, …) A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools C-feature-request Category: A feature request, i.e: not implemented / a PR. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants