rustc_attr_data_structures/
version.rs

1use std::fmt::{self, Display};
2
3use rustc_macros::{Decodable, Encodable, HashStable_Generic, current_rustc_version};
4
5#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
6#[derive(HashStable_Generic)]
7pub struct RustcVersion {
8    pub major: u16,
9    pub minor: u16,
10    pub patch: u16,
11}
12
13impl RustcVersion {
14    pub const CURRENT: Self = current_rustc_version!();
15}
16
17impl Display for RustcVersion {
18    fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
19        write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)
20    }
21}