From a8f7e244b785feb1b1d696abf0a7efb5cb7aed30 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Fri, 16 Sep 2022 11:01:02 +0400 Subject: Refactor rustc lint API --- compiler/rustc_error_messages/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'compiler/rustc_error_messages/src') diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index ff33ae7e8f2..fb7f89d7a28 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -357,6 +357,17 @@ impl> From for DiagnosticMessage { } } +/// A workaround for "good path" ICEs when formatting types in disables lints. +/// +/// Delays formatting until `.into(): DiagnosticMessage` is used. +pub struct DelayDm(pub F); + +impl String> From> for DiagnosticMessage { + fn from(DelayDm(f): DelayDm) -> 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 -- cgit 1.4.1-3-g733a5