dtolnay / rustversion

Conditional compilation according to rustc compiler version
Apache License 2.0
334 stars 15 forks source link

Support MSRV #36

Closed joshlf closed 2 years ago

joshlf commented 2 years ago

It would be nice if there were a way to conditionally compile based on a crate's MSRV - something like #[rustversion::msrv]. Perhaps this could consume the rust-version key from Cargo.toml or the CARGO_PKG_RUST_VERSION environment variable, which Cargo sets based on that Cargo.toml key.

dtolnay commented 2 years ago

I would prefer not to build this into this crate, but it seems reasonable for someone else to maintain in a different macro.

joshlf commented 2 years ago

How would you feel about a simpler #[rustversion::env(VAR = "value")] that could be used by downstream code to implement things like #[rustversion::env(CARGO_PKG_RUST_VERSION = "1.2.3")]? I'd be happy to do the implementation work and put up a PR. Obviously no worries if this doesn't fit into your vision for rustversion/you don't want to maintain it/etc.

dtolnay commented 2 years ago

Not interested in that either.