Skip to main content

AnalysisError

Enum AnalysisError 

Source
#[non_exhaustive]
pub enum AnalysisError {
Show 13 variants Interrupted, MissingDocument, ImmutableDocument, InvalidSpan, UninitAttribute, UninitSlot, MissingAttribute, MissingSlot, UninitSemantics, MissingSemantics, TypeMismatch, MissingFeature, Timeout,
}
Expand description

An error occurring during semantics analysis.

There are two types of errors:

  • An abnormal that indicate an error in the user code, such as an issue in the Grammar configuration or misuse of the analysis API. In this case, it is recommended to panic as early as possible such that the panic backtrace will point to the exact piece of code of where the error occurred.

  • A normal error that should be propagated up to the caller of the current function that returns an AnalysisResult. For example, such errors should be returned from the Computable::compute implementations.

For convenience, the AnalysisResult type extended by the AnalysisResultEx trait with the AnalysisResultEx::unwrap_abnormal function that panics in place if the underlying error is abnormal, or passes the Result object through if the underlying variant is Ok or denotes a normal error.

Currently, the AnalysisError defines two normal errors:

  • The Interrupted error, which denotes that the operation cannot be completed, because the underlying task has been signaled to shut down.

  • The Timeout error, which denotes that the operation computation exceeded predefined timeout. This error may occur due to recursion in the attributes graph, which is a user code issue, or just a normal time out if the operation takes too long. In the production builds (when the debug_assertions feature is disabled), this type of error is a normal error, but in non-production builds, this error considered abnormal.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Interrupted

The operation cannot be completed because the underlying task has been signaled to shut down.

This error is a normal error.

§

MissingDocument

The document referred to by the specified id does not exits in the Analyzer.

This error is an abnormal error.

§

ImmutableDocument

The content edit operation cannot be performed on the specified document, because the document is not mutable.

This error is an abnormal error.

§

InvalidSpan

The specified span is not valid for the specified document.

This error is an abnormal error.

§

UninitAttribute

An attempt to access an Attr object which is not fully initialized.

See Feature Lifetime for details.

This error is an abnormal error.

§

UninitSlot

An attempt to access an Slot object which is not fully initialized.

See Feature Lifetime for details.

This error is an abnormal error.

§

MissingAttribute

The referred attribute does not exist in the Analyzer’s semantic graph.

This error is an abnormal error.

§

MissingSlot

The referred slot does not exist in the Analyzer’s semantic graph.

This error is an abnormal error.

§

UninitSemantics

An attempt to access a Semantics object which is not fully initialized.

See Feature Lifetime for details.

This error is an abnormal error.

§

MissingSemantics

The specified syntax tree node does not have semantics.

This error may occur, for example, if the Grammar object does not specify any semantics for any node, or if a particular type of the node does not specify semantics.

This error is an abnormal error.

§

TypeMismatch

The attribute value type is differ from the specified type.

This error is an abnormal error.

§

MissingFeature

The specified feature does not exist in the syntax tree node’s semantics.

This error is an abnormal error.

§

Timeout

Operation timeout.

This error indicates that the requested operation takes too long to finish, which is generally acceptable, or if the semantics graph has a recursion, which is an issue in the semantics design.

This error is a normal error if the target build is a production build (debug_assertions feature is disabled). Otherwise, the error is abnormal.

Implementations§

Source§

impl AnalysisError

Source

pub fn is_abnormal(&self) -> bool

Returns true if the underlying error object denotes an issue in the user code, or in the Grammar configuration.

Trait Implementations§

Source§

impl Clone for AnalysisError

Source§

fn clone(&self) -> AnalysisError

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for AnalysisError

Source§

impl Debug for AnalysisError

Source§

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

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

impl Display for AnalysisError

Source§

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

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

impl Eq for AnalysisError

Source§

impl Error for AnalysisError

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl Hash for AnalysisError

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for AnalysisError

Source§

fn cmp(&self, other: &AnalysisError) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for AnalysisError

Source§

fn eq(&self, other: &AnalysisError) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for AnalysisError

Source§

fn partial_cmp(&self, other: &AnalysisError) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for AnalysisError

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.