A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/trait.Diagnostic.html below:

Diagnostic in rustc_errors - Rust

pub trait Diagnostic<'a, G: EmissionGuarantee = ErrorGuaranteed> {
    // Required method
    fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, G>;
}
Expand description

Trait implemented by error types. This is rarely implemented manually. Instead, use #[derive(Diagnostic)] – see rustc_macros::Diagnostic.

When implemented manually, it should be generic over the emission guarantee, i.e.:

ⓘ
impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for Foo { ... }

rather than being specific:

ⓘ
impl<'a> Diagnostic<'a> for Bar { ... }  impl<'a> Diagnostic<'a, ()> for Baz { ... }

There are two reasons for this.

Source

Write out as a diagnostic out of DiagCtxt.

Source§ Source§

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4