Struct swc_common::errors::Diagnostic[][src]

pub struct Diagnostic {
    pub level: Level,
    pub message: Vec<(String, Style)>,
    pub code: Option<DiagnosticId>,
    pub span: MultiSpan,
    pub children: Vec<SubDiagnostic>,
    pub suggestions: Vec<CodeSuggestion>,
}

Fields

level: Levelmessage: Vec<(String, Style)>code: Option<DiagnosticId>span: MultiSpanchildren: Vec<SubDiagnostic>suggestions: Vec<CodeSuggestion>

Implementations

Cancel the diagnostic (a structured diagnostic must either be emitted or canceled or it will panic when dropped).

Add a span/label to be included in the resulting snippet. This is pushed onto the MultiSpan that was created when the diagnostic was first built. If you don’t call this function at all, and you just supplied a Span to create the diagnostic, then the snippet will just include that Span, which is called the primary span.

👎 Deprecated:

Use span_suggestion_short_with_applicability

Prints out a message with a suggested edit of the code. If the suggestion is presented inline it will only show the text message and not the text.

See CodeSuggestion for more information.

👎 Deprecated:

Use span_suggestion_with_applicability

Prints out a message with a suggested edit of the code.

In case of short messages and a simple suggestion, rustc displays it as a label like

“try adding parentheses: (tup.0).1

The message

  • should not end in any punctuation (a : is added automatically)
  • should not be a question
  • should not contain any parts like “the following”, “as shown”
  • may look like “to do xyz, use” or “to do xyz, use abc”
  • may contain a name of a function, variable or type, but not whole expressions

See CodeSuggestion for more information.

👎 Deprecated:

Use multipart_suggestion_with_applicability

👎 Deprecated:

Use span_suggestions_with_applicability

Prints out a message with multiple suggested edits of the code.

This is a suggestion that may contain mistakes or fillers and should be read and understood by a human.

Used by a lint. Copies over all details but the “main message”.

Convenience function for internal use, clients should use one of the public methods above.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.