Implement IntoDiagArg for RustcVersion

This commit is contained in:
Xiretza 2024-04-21 19:56:00 +00:00
parent 3b979aebfe
commit 56bca95875

View File

@ -1,5 +1,10 @@
use rustc_macros::{current_rustc_version, Decodable, Encodable, HashStable_Generic};
use std::fmt::{self, Display};
use std::{
borrow::Cow,
fmt::{self, Display},
};
use rustc_errors::IntoDiagArg;
#[derive(Encodable, Decodable, Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(HashStable_Generic)]
@ -18,3 +23,9 @@ fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(formatter, "{}.{}.{}", self.major, self.minor, self.patch)
}
}
impl IntoDiagArg for RustcVersion {
fn into_diag_arg(self) -> rustc_errors::DiagArgValue {
rustc_errors::DiagArgValue::Str(Cow::Owned(self.to_string()))
}
}