rust/compiler/rustc_attr_data_structures/src/version.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
658 B
Rust
Raw Normal View History

2024-04-21 19:56:00 +00:00
use std::fmt::{self, Display};
2025-02-09 21:50:03 +00:00
use rustc_macros::{
Decodable, Encodable, HashStable_Generic, PrintAttribute, current_rustc_version,
};
use crate::PrintAttribute;
2023-10-27 00:18:21 +00:00
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
2025-02-09 21:50:03 +00:00
#[derive(HashStable_Generic, PrintAttribute)]
2023-10-27 00:18:21 +00:00
pub struct RustcVersion {
pub major: u16,
pub minor: u16,
pub patch: u16,
}
impl RustcVersion {
pub const CURRENT: Self = current_rustc_version!();
2023-10-27 00:18:21 +00:00
}
impl Display for RustcVersion {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)
}
}