Simplify the current_rustc_version macro.

It currently has the syntax
`current_rustc_version!(env!("CFG_RELEASE"))` where the
`env!("CFG_RELEASE")` part looks like a normal expression but it is
actually parsed and processed by the `current_rustc_version` macro.

The documented rationale for this is that you'll find it if you grep for
`env!("CFG_RELEASE")`. But I think that's of very little use -- I would
personally grep for just "CFG_RELEASE" -- and it complicates the macro,
requiring the use of `syn`.

This commit simplifies the macro.
This commit is contained in:
Nicholas Nethercote 2023-11-08 17:05:44 +11:00
parent fdaaaf9f92
commit 49908b4d90
3 changed files with 12 additions and 30 deletions

View file

@ -26,6 +26,9 @@ mod symbols;
mod type_foldable;
mod type_visitable;
// Reads the rust version (e.g. "1.75.0") from the CFG_RELEASE env var and
// produces a `RustcVersion` literal containing that version (e.g.
// `RustcVersion { major: 1, minor: 75, patch: 0 }`).
#[proc_macro]
pub fn current_rustc_version(input: TokenStream) -> TokenStream {
current_version::current_version(input)