move DiagnosticArgFromDisplay into rustc_errors
This commit is contained in:
parent
0ad57d8502
commit
694a010a5c
4 changed files with 36 additions and 31 deletions
|
@ -40,6 +40,26 @@ pub trait IntoDiagnosticArg {
|
|||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static>;
|
||||
}
|
||||
|
||||
pub struct DiagnosticArgFromDisplay<'a>(pub &'a dyn fmt::Display);
|
||||
|
||||
impl IntoDiagnosticArg for DiagnosticArgFromDisplay<'_> {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
self.0.to_string().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a dyn fmt::Display> for DiagnosticArgFromDisplay<'a> {
|
||||
fn from(t: &'a dyn fmt::Display) -> Self {
|
||||
DiagnosticArgFromDisplay(t)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: fmt::Display> From<&'a T> for DiagnosticArgFromDisplay<'a> {
|
||||
fn from(t: &'a T) -> Self {
|
||||
DiagnosticArgFromDisplay(t)
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! into_diagnostic_arg_using_display {
|
||||
($( $ty:ty ),+ $(,)?) => {
|
||||
$(
|
||||
|
|
|
@ -371,8 +371,8 @@ impl fmt::Display for ExplicitBug {
|
|||
impl error::Error for ExplicitBug {}
|
||||
|
||||
pub use diagnostic::{
|
||||
AddSubdiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgValue, DiagnosticId,
|
||||
DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
|
||||
AddSubdiagnostic, DecorateLint, Diagnostic, DiagnosticArg, DiagnosticArgFromDisplay,
|
||||
DiagnosticArgValue, DiagnosticId, DiagnosticStyledString, IntoDiagnosticArg, SubDiagnostic,
|
||||
};
|
||||
pub use diagnostic_builder::{DiagnosticBuilder, EmissionGuarantee, LintDiagnosticBuilder};
|
||||
use std::backtrace::Backtrace;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue