SubdiagMessage in rustc_errors - Rust (original) (raw)

Enum SubdiagMessage

Source

pub enum SubdiagMessage {
    Str(Cow<'static, str>),
    Translated(Cow<'static, str>),
    FluentIdentifier(Cow<'static, str>),
    FluentAttr(Cow<'static, str>),
}

Expand description

Abstraction over a message in a subdiagnostic (i.e. label, note, help, etc) to support both translatable and non-translatable diagnostic messages.

Translatable messages for subdiagnostics are typically attributes attached to a larger Fluent message so messages of this type must be combined with a DiagMessage (usingDiagMessage::with_subdiagnostic_message) before rendering. However, subdiagnostics from the Subdiagnostic derive refer to Fluent identifiers directly.

§

Non-translatable diagnostic message.

§

Translatable message which has already been translated eagerly.

Some diagnostics have repeated subdiagnostics where the same interpolated variables would be instantiated multiple times with different values. These subdiagnostics’ messages are translated when they are added to the parent diagnostic, producing this variant ofDiagMessage.

§

Identifier of a Fluent message. Instances of this variant are generated by theSubdiagnostic derive.

§

Source§

Source§

Converts to this type from the input type.

Source§

Source§

Converts to this type from the input type.

Source§

Translating into a subdiagnostic message from a diagnostic message is a little strange - but the subdiagnostic functions (e.g. span_label) take a SubdiagMessage and the subdiagnostic derive refers to typed identifiers that are DiagMessages, so need to be able to convert between these, as much as they’ll be converted back into DiagMessageusing with_subdiagnostic_message eventually. Don’t use this other than for the derive.

Source§

Converts to this type from the input type.

Source§

Source§

Converts to this type from the input type.

§

§

§

§

§

§

§

§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 32 bytes

Size for each variant: