Skip to main content

IrError

Enum IrError 

Source
pub enum IrError {
Show 17 variants UnsupportedSchemaVersion { found: u32, expected: u32, }, UnknownValue { instr: u32, value: u32, }, UnknownBlock { instr: u32, block: u32, }, MissingTerminator { block: u32, expected: &'static str, }, MisplacedTerminator { block: u32, instr: u32, }, WrongTier { instr: u32, kind: &'static str, }, OperandShape { instr: u32, detail: &'static str, }, DuplicateInstrId { id: u32, }, DuplicateBlockId { id: u32, }, NonFiniteFloat { instr: u32, }, RepeatsOutOfRange { count: u64, }, PathIndexOutOfRange { instr: u32, index: u64, }, MultipleUses { instr: u32, value: u32, }, BlockObservedTwice { block: u32, }, ExpectedLoad { instr: u32, lhs: u32, }, NegatedExists { instr: u32, }, WrongBlockKind { block: u32, expected: &'static str, },
}
Expand description

A way a Program can be malformed.

Variants§

§

UnsupportedSchemaVersion

The program’s schema_version is not one this build understands.

Fields

§found: u32

The version found in the program.

§expected: u32

The version this build supports.

§

UnknownValue

An instruction referenced a value that is not defined earlier in its block.

Fields

§instr: u32

The referencing instruction.

§value: u32

The referenced value.

§

UnknownBlock

Observe targeted a missing block, or one that is not a comparison block.

Fields

§instr: u32

The referencing instruction.

§block: u32

The referenced block.

§

MissingTerminator

A block does not end in the terminator its kind requires.

Fields

§block: u32

The offending block.

§expected: &'static str

The terminator the block’s kind requires.

§

MisplacedTerminator

A terminator appeared somewhere other than the end of its block.

Fields

§block: u32

The offending block.

§instr: u32

The misplaced terminator.

§

WrongTier

An op appeared in a block of the wrong kind.

Fields

§instr: u32

The offending instruction.

§kind: &'static str

The block kind it appeared in.

§

OperandShape

A Compare’s operand shape does not match its operator.

Fields

§instr: u32

The offending instruction.

§detail: &'static str

What was expected.

§

DuplicateInstrId

Two instructions share an id.

Fields

§id: u32

The repeated id.

§

DuplicateBlockId

Two blocks share an id.

Fields

§id: u32

The repeated id.

§

NonFiniteFloat

A float that STIX pattern syntax cannot express.

The patterning language has no notation for NaN or infinity, so such a value could never be rendered back to text.

Fields

§instr: u32

The offending instruction.

§

RepeatsOutOfRange

A Repeats count is larger than the pattern lexer can read back.

The lexer reads integer literals as i64, so REPEATS <n> TIMES parses only for n <= i64::MAX. A larger count would render to text that does not parse. Zero is accepted by the grammar and so is accepted here.

Fields

§count: u64

The offending count.

§

PathIndexOutOfRange

A Load path has a list index larger than the pattern lexer can read back.

The lexer reads integer literals as i64, so [n] in a path parses only for n <= i64::MAX. A larger index would render to text that does not parse.

Fields

§instr: u32

The offending instruction.

§index: u64

The offending index.

§

MultipleUses

One value is consumed by more than one operand.

Pattern text has no way to name a shared value, so a shared subexpression would have to be re-rendered once per use — making output exponential in the number of instructions. Requiring each value to have at most one consumer keeps every value expression a tree, which is what render already assumes.

This covers values only. A comparison block is not a value; its reuse is bounded separately, by IrError::BlockObservedTwice.

Fields

§instr: u32

The referencing instruction.

§value: u32

The value that was already used.

§

BlockObservedTwice

A comparison block is the target of more than one Observe.

Observe names a block rather than a value, so the single-use rule does not cover it. Pattern text cannot name a shared block either: each Observe is rendered as its own copy of the block, so sharing one block among k observes makes output grow with k times the block’s size — quadratic in the program. Requiring each block to be observed at most once keeps rendered size linear. lower already allocates one block per observation.

Fields

§block: u32

The block that was observed again.

§

ExpectedLoad

A Compare’s left-hand side is not a Load.

The renderer takes the compared object path from the Load it names; any other instruction leaves the path missing from the rendered text.

Fields

§instr: u32

The offending instruction.

§lhs: u32

The value it named as its left-hand side.

§

NegatedExists

An EXISTS comparison is marked negated.

The grammar has no negated form of EXISTS, so the negation could not be rendered and would be silently dropped.

Fields

§instr: u32

The offending instruction.

§

WrongBlockKind

A block has the wrong BlockKind for its position.

Fields

§block: u32

The offending block.

§expected: &'static str

The kind its position requires.

Trait Implementations§

Source§

impl Clone for IrError

Source§

fn clone(&self) -> IrError

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 Debug for IrError

Source§

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

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

impl Display for IrError

Source§

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

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

impl Eq for IrError

Source§

impl Error for IrError

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 PartialEq for IrError

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for IrError

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 = 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.