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
Ignored
InvalidGenericArg
InvalidAssocReft
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.
Emitted(ErrorGuaranteed)
Implementations§
Trait Implementations§
Source§impl<__D: SpanDecoder> Decodable<__D> for QueryErr
impl<__D: SpanDecoder> Decodable<__D> for QueryErr
Source§impl<'a> Diagnostic<'a> for QueryErr
impl<'a> Diagnostic<'a> for QueryErr
Source§fn into_diag(
self,
dcx: DiagCtxtHandle<'a>,
_level: Level,
) -> Diag<'a, ErrorGuaranteed>
fn into_diag( self, dcx: DiagCtxtHandle<'a>, _level: Level, ) -> Diag<'a, ErrorGuaranteed>
DiagCtxt
.Source§impl<__E: SpanEncoder> Encodable<__E> for QueryErr
impl<__E: SpanEncoder> Encodable<__E> for QueryErr
Source§impl From<ErrorGuaranteed> for QueryErr
impl From<ErrorGuaranteed> for QueryErr
Source§fn from(err: ErrorGuaranteed) -> Self
fn from(err: ErrorGuaranteed) -> Self
Auto Trait Implementations§
impl Freeze for QueryErr
impl RefUnwindSafe for QueryErr
impl Send for QueryErr
impl Sync for QueryErr
impl Unpin for QueryErr
impl UnwindSafe for QueryErr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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