I’m writing a code-generation library that is called from build.rs of projects using it (ructe, a webpage template language). In that, it would be nice to generate edition 2018-compatible code in crates that has enabled edition 2018, while still generating edition 2015-compatible code otherwise.
To make that easier, it would be very nice if cargo defined an edition variable
RUST_EDITION (or something similiar), setting it to
2018 if edition 2018 is enabled and either setting it to
2015 or leaving it undefined otherwise.
I don’t see such a variable in the cargo book and I don’t find anything like it when I test with rustc 1.31.0-nightly (423d81098 2018-10-08). Has it been suggested earlier? Should it be implemented?
Otherwise, my library could of course find and parse the
Cargo.toml of the user crate, but I think that seems more complicated than it should be.