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

Builder option to avoid cleanup on Drop #122

Open
Mark-Simulacrum opened this issue Aug 9, 2020 · 1 comment
Open

Builder option to avoid cleanup on Drop #122

Mark-Simulacrum opened this issue Aug 9, 2020 · 1 comment

Comments

@Mark-Simulacrum
Copy link

rustc has a -Csave-temps option that is intended for debugging (or other cases where temporary file access is useful).

We used to have code like this, but it behaved incorrectly in the presence of panics in the intermediary code. It would be nice to have a boolean flag on the builder that would let us do something like .cleanup(opts.save_temps) and that would create a TempDir which doesn't delete itself on Drop.

For now we've implemented this in rustc itself atop TempDir, but upstreaming it would be more convenient API wise.

let tmpdir = ...;

// a bunch of code runs, using tmpdir

if opts.save_temps {
    let _ = tmpdir.into_path();
}
@Stebalien
Copy link
Owner

Sounds like a good feature.

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

No branches or pull requests

2 participants