]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_error_messages/src/lib.rs
Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebank
[rust.git] / compiler / rustc_error_messages / src / lib.rs
index abf98a9621e78eb3db746b081ec04864ad328bb0..bf9248f99b695dd65d23bb38134359abdc268a89 100644 (file)
@@ -358,6 +358,17 @@ fn from(s: S) -> Self {
     }
 }
 
+/// 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