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.
Foo
could be emitted at any level â level
is passed in to into_diag
from outside. Even if in practice it is always emitted at a single level, we let the diagnostic creation/emission site determine the level (by using create_err
, emit_warn
, etc.) rather than the Diagnostic
impl.Write out as a diagnostic out of DiagCtxt
.
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