I want to do something slightly odd. I'm assuming there are no means to do what I want, but I just wasted some time chasing down an issue relating to this, so:
I have a build system for a somewhat large project written in Rust. It has two major phases; one single-threaded which transitions over to the other, which is multi-threaded. During the single-threaded phase it's perfectly okay for a functions to change the current working directory (because each new major function changes its directory to where it needs to be).
For obvious reasons changing directory in a multi-threaded is a major no-no.
I would like to block
std::env::set_current_dir from being called. Yes, I know there are other ways to do that, like
libc::chdir. If someone is actively looking for a footgun, there isn't much I can do about it -- but what I want to protect against is someone down the line accidentally not being aware of a particular module belonging to the multithreaded phase and calling
set_current_dir in it. (This constraint could be enforced on a module basis).
Is there something akin to:
Doesn't really matter if it's compile time or runtime, as long as it goes very kaboom so it's impossible to miss.