Type Alias rustc_errors::PErr

source ·
pub type PErr<'a> = Diag<'a>;

Aliased Type§

struct PErr<'a> {
    pub dcx: &'a DiagCtxt,
    diag: Option<Box<DiagInner>>,
    _marker: PhantomData<ErrorGuaranteed>,
}

Fields§

§dcx: &'a DiagCtxt§diag: Option<Box<DiagInner>>

Why the Option? It is always Some until the Diag is consumed via emit, cancel, etc. At that point it is consumed and replaced with None. Then drop checks that it is None; if not, it panics because a diagnostic was built but not used.

Why the Box? DiagInner is a large type, and Diag is often used as a return value, especially within the frequently-used PResult type. In theory, return value optimization (RVO) should avoid unnecessary copying. In practice, it does not (at the time of writing).

§_marker: PhantomData<ErrorGuaranteed>

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