dtolnay / rustversion

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

Add `msrv` macro #49

Closed robjtede closed 6 months ago

robjtede commented 6 months ago

With the understanding that this goes against your views in #36, ~this seems to be a minimal implementation of an MSRV-condition macro based on the built-in CARGO_PKG_RUST_VERSION env var.~

For what it's worth, I do think this would be a valuable addition to this crate. My use case in particular is guarding trybuild tests to MSRV to ensure stable stderr across new rustcs.

Had to file a draft here as my fork didn't run CI, idk why.

robjtede commented 6 months ago

I'm discovering and recalling that compiler env vars are not evaluated at the callsite so the CARGO_PKG_RUST_VERSION strategy is not valid. Will investigate further what a minimal implementation would look like.

robjtede commented 6 months ago

No worries. Worth a shot in case views had changed in the months since that issue.