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

Closed
Mark-Simulacrum opened this issue Aug 9, 2020 · 3 comments
Closed

Builder option to avoid cleanup on Drop #122

Mark-Simulacrum opened this issue Aug 9, 2020 · 3 comments

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.

@ethanuppal
Copy link

As a comment (and a bump on this), it might be instructive to look at Prof. Adrian Sampson's implementation of a temporary directory (calyxir/calyx#2072); I had originally used a TempDir, but as no "keep directory" option was available, he opted to create a new abstraction for it.

@Stebalien
Copy link
Owner

Issue with more discussion here: #194 (comment)

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

3 participants