flux_middle::queries

Enum QueryErr

Source
pub enum QueryErr {
    Unsupported {
        def_id: DefId,
        err: UnsupportedErr,
    },
    Ignored {
        def_id: DefId,
    },
    InvalidGenericArg {
        def_id: DefId,
    },
    InvalidAssocReft {
        container_def_id: DefId,
        name: Symbol,
    },
    Bug {
        def_id: Option<DefId>,
        location: String,
        msg: String,
    },
    Emitted(ErrorGuaranteed),
}
Expand description

An error produced by a query.

We make a distinction between errors reported at def-site and errors reported at use-site.

For most errors reported at the def-site of an item, it makes little sense to check the definition of dependent items. For example, if a function signature is ill-formed, checking the body of another function that calls it, can produce confusing errors. In some cases, we can even fail to produce a signature for a function in which case we can’t even check its call sites. For these cases, we emit an error at the definition site and return a QueryErr::Emitted. When checking a dependent, we detect this and early return without reporting any errors at the use-site.

Other errors are better reported at the use-site. For example, if some code calls a function from an external crate that has unsupported features, we ought to report the error at the call-site, because it would be confusing to only mention the definition of the external function without showing which part of the code is calling it. To attach a span to an error one can use QueryErr::at to get a QueryErrAt.

Both QueryErr and QueryErrAt implement Diagnostic. The implementation for QueryErr reports the error at the definition site, while the implementation for QueryErrAt reports it at the (attached) use-site span. This allows us to play a bit lose because we can emit an error without attaching a span, but this means we may forget to attach spans at some places. We should consider not implementing Diagnostic for QueryErr such that we always make the distinction between use-site and def-site explicit, e.g., we could have methods QueryErr::at_use_site and QueryErr::at_def_site returning types with different implementations of Diagnostic.

Variants§

§

Unsupported

Fields

§def_id: DefId
§

Ignored

Fields

§def_id: DefId
§

InvalidGenericArg

Fields

§def_id: DefId
§

InvalidAssocReft

Fields

§container_def_id: DefId
§name: Symbol
§

Bug

Used to report bugs, typically this means executing an arm in a match we thought it was unreachable. Use this instead of panicking if it is easy to return a QueryErr. Use QueryErr::bug or crate::query_bug! to construct this variant to track source location.

Fields

§def_id: Option<DefId>
§location: String
§

Emitted(ErrorGuaranteed)

Implementations§

Source§

impl QueryErr

Source

pub fn unsupported(def_id: DefId, err: UnsupportedErr) -> Self

Source

pub fn bug(def_id: Option<DefId>, msg: impl ToString) -> Self

Source

pub fn at(self, span: Span) -> QueryErrAt

Trait Implementations§

Source§

impl Clone for QueryErr

Source§

fn clone(&self) -> QueryErr

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for QueryErr

Source§

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

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

impl<__D: SpanDecoder> Decodable<__D> for QueryErr

Source§

fn decode(__decoder: &mut __D) -> Self

Source§

impl<'a> Diagnostic<'a> for QueryErr

Source§

fn into_diag( self, dcx: DiagCtxtHandle<'a>, _level: Level, ) -> Diag<'a, ErrorGuaranteed>

Write out as a diagnostic out of DiagCtxt.
Source§

impl<__E: SpanEncoder> Encodable<__E> for QueryErr

Source§

fn encode(&self, __encoder: &mut __E)

Source§

impl From<ErrorGuaranteed> for QueryErr

Source§

fn from(err: ErrorGuaranteed) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<P> IntoQueryParam<P> for P

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.