]> 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 ff33ae7e8f224edd0971202b11807c08a75422cf..bf9248f99b695dd65d23bb38134359abdc268a89 100644 (file)
@@ -41,6 +41,7 @@
     borrowck => "../locales/en-US/borrowck.ftl",
     builtin_macros => "../locales/en-US/builtin_macros.ftl",
     const_eval => "../locales/en-US/const_eval.ftl",
+    codegen_gcc => "../locales/en-US/codegen_gcc.ftl",
     driver => "../locales/en-US/driver.ftl",
     expand => "../locales/en-US/expand.ftl",
     session => "../locales/en-US/session.ftl",
@@ -357,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