X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=compiler%2Frustc_error_messages%2Fsrc%2Flib.rs;h=bf9248f99b695dd65d23bb38134359abdc268a89;hb=744e397d8855f7da87d70aa8d0bd9e0f5f0b51a1;hp=b6e0f3faa73cb919c48269c2131572dddbdff448;hpb=cba4a389b3961a2fd72e01bd6cb0b0e065edaf3d;p=rust.git diff --git a/compiler/rustc_error_messages/src/lib.rs b/compiler/rustc_error_messages/src/lib.rs index b6e0f3faa73..bf9248f99b6 100644 --- a/compiler/rustc_error_messages/src/lib.rs +++ b/compiler/rustc_error_messages/src/lib.rs @@ -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", @@ -268,14 +269,14 @@ pub fn fallback_fluent_bundle( /// Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent /// message so messages of this type must be combined with a `DiagnosticMessage` (using /// `DiagnosticMessage::with_subdiagnostic_message`) before rendering. However, subdiagnostics from -/// the `SessionSubdiagnostic` derive refer to Fluent identifiers directly. +/// the `Subdiagnostic` derive refer to Fluent identifiers directly. #[rustc_diagnostic_item = "SubdiagnosticMessage"] pub enum SubdiagnosticMessage { /// Non-translatable diagnostic message. // FIXME(davidtwco): can a `Cow<'static, str>` be used here? Str(String), /// Identifier of a Fluent message. Instances of this variant are generated by the - /// `SessionSubdiagnostic` derive. + /// `Subdiagnostic` derive. FluentIdentifier(FluentId), /// Attribute of a Fluent message. Needs to be combined with a Fluent identifier to produce an /// actual translated message. Instances of this variant are generated by the `fluent_messages` @@ -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(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