I have a procedural macro that needs to store semi-persistent state. The state needs to survive compilation runs and should be cleaned up when cargo clean
is run.
In the past, I used the ./target
directory this purpose. However, this was a mistake because some of the files my procedural macro would generated could conflict with those generated by rustc and cargo. The location of the target directory can also be changed from the default.
Note that this question is not a duplicate of Is it possible to store state within Rust's procedural macros?. That question covers procedural macro state in general while this question is about determining a suitable location within a crate's file structure.