diff options
| author | David Wood <david.wood@huawei.com> | 2022-08-30 17:00:20 +0100 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2023-01-30 17:11:34 +0000 |
| commit | f7b42102e68537c6b0bbb3a1e83c9db69820dfb3 (patch) | |
| tree | 4d68aca42bfbb5355e5a37ef9448e414cc549bed /compiler/rustc_errors/src | |
| parent | 59cc5e5d59796f5817d46b31450923597d9f8ae7 (diff) | |
| download | rust-f7b42102e68537c6b0bbb3a1e83c9db69820dfb3.tar.gz rust-f7b42102e68537c6b0bbb3a1e83c9db69820dfb3.zip | |
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>
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/diagnostic_impls.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_errors/src/diagnostic_impls.rs b/compiler/rustc_errors/src/diagnostic_impls.rs index dad5e98aac0..d5a5ef3b445 100644 --- a/compiler/rustc_errors/src/diagnostic_impls.rs +++ b/compiler/rustc_errors/src/diagnostic_impls.rs @@ -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 ),+ $(,)?) => { $( |
