Diagnostic in rustc_proc_macro - Rust
Description: A structure representing a diagnostic message and associated children messages.

Skip to main content

## Diagnostic

# Struct Diagnostic

Source

    pub struct Diagnostic {
        level: Level,
        message: String,
        spans: Vec<Span>,
        children: Vec<Diagnostic>,
    }

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)
Expand description

A structure representing a diagnostic message and associated children messages.

## Fields§

§`level: Level`
🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)
§`message: String`
🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)
§`spans: Vec<Span>`
🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)
§`children: Vec<Diagnostic>`
🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

## Implementations§

Source§

### impl Diagnostic

Source

#### pub fn new<T: Into<String>>(level: Level, message: T) -> Diagnostic

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Creates a new diagnostic with the given `level` and `message`.

Source

#### pub fn spanned<S, T>(spans: S, level: Level, message: T) -> Diagnostic
where S: MultiSpan, T: Into<String>,

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Creates a new diagnostic with the given `level` and `message` pointing to the given set of `spans`.

Source

#### pub fn span_error<S, T>(self, spans: S, message: T) -> Diagnostic
where S: MultiSpan, T: Into<String>,

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostics message to `self` with the `Level::Error` level, and the given `spans` and `message`.

Source

#### pub fn error<T: Into<String>>(self, message: T) -> Diagnostic

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostic message to `self` with the `Level::Error` level, and the given `message`.

Source

#### pub fn span_warning<S, T>(self, spans: S, message: T) -> Diagnostic
where S: MultiSpan, T: Into<String>,

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostics message to `self` with the `Level::Warning` level, and the given `spans` and `message`.

Source

#### pub fn warning<T: Into<String>>(self, message: T) -> Diagnostic

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostic message to `self` with the `Level::Warning` level, and the given `message`.

Source

#### pub fn span_note<S, T>(self, spans: S, message: T) -> Diagnostic
where S: MultiSpan, T: Into<String>,

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostics message to `self` with the `Level::Note` level, and the given `spans` and `message`.

Source

#### pub fn note<T: Into<String>>(self, message: T) -> Diagnostic

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostic message to `self` with the `Level::Note` level, and the given `message`.

Source

#### pub fn span_help<S, T>(self, spans: S, message: T) -> Diagnostic
where S: MultiSpan, T: Into<String>,

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostics message to `self` with the `Level::Help` level, and the given `spans` and `message`.

Source

#### pub fn help<T: Into<String>>(self, message: T) -> Diagnostic

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Adds a new child diagnostic message to `self` with the `Level::Help` level, and the given `message`.

Source

#### pub fn level(&self) -> Level

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Returns the diagnostic `level` for `self`.

Source

#### pub fn set_level(&mut self, level: Level)

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Sets the level in `self` to `level`.

Source

#### pub fn message(&self) -> &str

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Returns the message in `self`.

Source

#### pub fn set_message<T: Into<String>>(&mut self, message: T)

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Sets the message in `self` to `message`.

Source

#### pub fn spans(&self) -> &[Span]

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Returns the `Span`s in `self`.

Source

#### pub fn set_spans<S: MultiSpan>(&mut self, spans: S)

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Sets the `Span`s in `self` to `spans`.

Source

#### pub fn children(&self) -> Children<'_> ⓘ

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Returns an iterator over the children diagnostics of `self`.

Source

#### pub fn emit(self)

🔬This is a nightly-only experimental API. (`proc_macro_diagnostic` #54140)

Emit the diagnostic.

## Trait Implementations§

Source§

### impl Clone for Diagnostic

Source§

#### fn clone(&self) -> Diagnostic

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

#### fn clone_from(&mut self, source: &Self)

Performs copy-assignment from `source`. Read more
Source§

### impl Debug for Diagnostic

Source§

#### fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

## Auto Trait Implementations§

§

### impl !Send for Diagnostic

§

### impl !Sync for Diagnostic

§

### impl Freeze for Diagnostic

§

### impl RefUnwindSafe for Diagnostic

§

### impl Unpin for Diagnostic

§

### impl UnsafeUnpin for Diagnostic

§

### impl UnwindSafe for Diagnostic

## Blanket Implementations§

Source§

### impl<T> Any for T
where T: 'static + ?Sized,

Source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
Source§

### impl<T> Borrow<T> for T
where T: ?Sized,

Source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

### impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

### impl<T> CloneToUninit for T
where T: Clone,

Source§

#### unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (`clone_to_uninit` #126799)
Performs copy-assignment from `self` to `dest`. Read more
Source§

### impl<T> From<T> for T

Source§

#### fn from(t: T) -> T

Returns the argument unchanged.

Source§

### impl<T, U> Into<U> for T
where U: From<T>,

Source§

#### fn into(self) -> U

Calls `U::from(self)`.

That is, this conversion is whatever the implementation of `From<T> for U` chooses to do.

Source§

### impl<T> ToOwned for T
where T: Clone,

Source§

#### type Owned = T

The resulting type after obtaining ownership.
Source§

#### fn to_owned(&self) -> T

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

#### fn clone_into(&self, target: &mut T)

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

### impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

#### type Error = Infallible

The type returned in the event of a conversion error.
Source§

#### fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

### impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

#### type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

#### fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

## Layout§

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: 80 bytes