mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-27 19:16:36 +00:00
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.
20 lines
505 B
Rust
20 lines
505 B
Rust
use std::fmt::{self, Display};
|
|
|
|
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
#[derive(HashStable_Generic)]
|
|
pub struct RustcVersion {
|
|
pub major: u16,
|
|
pub minor: u16,
|
|
pub patch: u16,
|
|
}
|
|
|
|
impl RustcVersion {
|
|
pub const CURRENT: Self = current_rustc_version!();
|
|
}
|
|
|
|
impl Display for RustcVersion {
|
|
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)
|
|
}
|
|
}
|