Skip to content
This repository was archived by the owner on Aug 20, 2021. It is now read-only.

TempDir ignores errors in drop #5

Closed
cmbrandenburg opened this issue Aug 25, 2015 · 1 comment
Closed

TempDir ignores errors in drop #5

cmbrandenburg opened this issue Aug 25, 2015 · 1 comment

Comments

@cmbrandenburg
Copy link

Any reason why TempDir ignores errors when dropped?

I feel this is unsafe default behavior, as it could lead to a long-running process leaking temporary directories. To avoid this problem, a program must wrap TempDir and have the wrapper call TempDir::close in the wrapper's destructor—all to find out that an error occurred.

Here's an alternative. Suppose the TempDir destructor panicks on error instead of silently squashing it. This means a program's default behavior is to be notified of the error. If a program must prevent panicking—for whatever reason—then that program could do the wrapper thing and squash the error in the wrapper's destructor.

The alternative strategy is safer, as it requires action on the part of the programmer to ignore errors instead of requiring action on the part of the programmer to be notified of errors. In the case of TempDir's destructor, an error is probably a leak, the elimination of which is a big part of Rust's raison d'être.

@alexcrichton
Copy link
Contributor

Closing as working as intended, see comments here as well

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants