naga::common

Struct DiagnosticDisplay

Source
pub struct DiagnosticDisplay<T>(pub T);
Expand description

A wrapper for displaying Naga IR terms in diagnostic output.

For some Naga IR type T, DiagnosticDisplay<T> implements core::fmt::Display in a way that displays values of type T appropriately for diagnostic messages presented to human readers.

For example, the implementation of Display for DiagnosticDisplay<Scalar> formats the type represented by the given Scalar appropriately for users.

Some types like Handle<Type> require contextual information like a type arena to be displayed. In such cases, we implement Display for a type like DiagnosticDisplay<(Handle<Type>, GlobalCtx)>, where the GlobalCtx type provides the necessary context.

Do not implement this type for TypeInner, as that does not have enough information to display struct types correctly.

If you only need debugging output, DiagnosticDebug uses easier-to-obtain context types but still does a good enough job for logging or debugging.

§Language-sensitive diagnostics

Diagnostic output ought to depend on the source language from which the IR was produced: diagnostics resulting from processing GLSL code should use GLSL type syntax, for example. That means that DiagnosticDisplay ought to include some indication of which notation to use.

For the moment, only WGSL output is implemented, so DiagnosticDisplay lacks any support for this (#7268). However, the plan is that all language-independent code in Naga should use DiagnosticDisplay wherever appropriate, such that when its definition is expanded to include some indication of the right source language to use, any use site that does not supply this indication will provoke a compile-time error.

Tuple Fields§

§0: T

Trait Implementations§

Source§

impl Display for DiagnosticDisplay<(&TypeResolution, GlobalCtx<'_>)>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for DiagnosticDisplay<(&str, &Rule, GlobalCtx<'_>)>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for DiagnosticDisplay<(Handle<Type>, GlobalCtx<'_>)>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for DiagnosticDisplay<Scalar>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for DiagnosticDisplay<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for DiagnosticDisplay<T>
where T: RefUnwindSafe,

§

impl<T> Send for DiagnosticDisplay<T>
where T: Send,

§

impl<T> Sync for DiagnosticDisplay<T>
where T: Sync,

§

impl<T> Unpin for DiagnosticDisplay<T>
where T: Unpin,

§

impl<T> UnwindSafe for DiagnosticDisplay<T>
where T: UnwindSafe,

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> 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> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.