diff options
Diffstat (limited to 'compiler/rustc_error_messages/src/lib.rs')
| -rw-r--r-- | compiler/rustc_error_messages/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index abf98a9621e..bf9248f99b6 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -358,6 +358,17 @@ impl<S: Into<String>> From<S> for DiagnosticMessage { } } +/// A workaround for "good path" ICEs when formatting types in disables lints. +/// +/// Delays formatting until `.into(): DiagnosticMessage` is used. +pub struct DelayDm<F>(pub F); + +impl<F: FnOnce() -> String> From<DelayDm<F>> for DiagnosticMessage { + fn from(DelayDm(f): DelayDm<F>) -> Self { + DiagnosticMessage::from(f()) + } +} + /// Translating *into* a subdiagnostic message from a diagnostic message is a little strange - but /// the subdiagnostic functions (e.g. `span_label`) take a `SubdiagnosticMessage` and the /// subdiagnostic derive refers to typed identifiers that are `DiagnosticMessage`s, so need to be |
