errors: implement IntoDiagnosticArg for &T
Implement `IntoDiagnosticArg` for `&'a T` when `T` implements `IntoDiagnosticArg` and `Clone`. Makes it easier to write diagnostic structs that borrow something which implements `IntoDiagnosticArg`. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
@@ -36,6 +36,12 @@ impl<'a, T: fmt::Display> From<&'a T> for DiagnosticArgFromDisplay<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Clone + IntoDiagnosticArg> IntoDiagnosticArg for &'a T {
|
||||
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> {
|
||||
self.clone().into_diagnostic_arg()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! into_diagnostic_arg_using_display {
|
||||
($( $ty:ty ),+ $(,)?) => {
|
||||
$(
|
||||
|
||||
Reference in New Issue
Block a user