rustversion_msrv/
lib.rs

1//! Conditional compilation according manifest MSRV.
2//!
3//! # Selectors
4//!
5//! - `#[rustversion_msrv::msrv]`
6//!   
7//!   True on the **call-site** crate's `rust-version` field, i.e., its minimum supported Rust
8//!   version (MSRV).
9//!
10//! # Use Cases
11//!
12//! The motivating use case for the `msrv` macro in this crate is to ensure a stable compiler error
13//! output when running negative trybuild tests. Guarding your test function like this means you
14//! only need to update the .stderr files when you bump your MSRV, not (potentially) every stable
15//! release (or worse). Of course, try make sure that your CI is actually running an MSRV job in its
16//! set.
17//!
18//! ```
19//! #[rustversion_msrv::msrv]
20//! #[test]
21//! fn trybuild() {
22//!    // ...
23//! }
24//! ```
25
26extern crate proc_macro;
27
28use proc_macro::TokenStream;
29
30mod error;
31mod expand;
32mod expr;
33mod iter;
34mod release;
35mod token;
36mod version;
37
38use self::version::Version;
39
40const RUST_VERSION: Version = include!(concat!(env!("OUT_DIR"), "/version.expr"));
41
42#[proc_macro_attribute]
43pub fn msrv(args: TokenStream, input: TokenStream) -> TokenStream {
44    expand::cfg("msrv", args, input)
45}