#[non_exhaustive]pub enum ValidationError {
MissingTerminator {
block: Block,
},
BlockOutOfRange {
block: Block,
},
ValueOutOfRange {
value: Value,
},
EntryBranchTarget {
block: Block,
},
ArgCountMismatch {
block: Block,
expected: usize,
found: usize,
},
TypeMismatch {
value: Value,
expected: Type,
found: Type,
},
NotNumeric {
value: Value,
found: Type,
},
ReturnValueExpected {
expected: Type,
},
UseBeforeDef {
value: Value,
block: Block,
},
InconsistentDefinition {
value: Value,
},
}Expand description
A reason a Function is not well-formed.
Function::validate returns the first one it finds. Every variant names the
offending entity so a caller can point a diagnostic at it. The set is
#[non_exhaustive]: future checks may add variants without it being a breaking
change, so a match on it must include a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MissingTerminator
A block has no terminator. Every block must end in exactly one. Set the block’s terminator before finishing the function.
BlockOutOfRange
A terminator names a block that does not exist in the function. The branch target is a stale or fabricated handle; rebuild it from a block the function actually contains.
ValueOutOfRange
An instruction or terminator references a value that does not exist in the function. The handle is stale or from another function; values are scoped to the function that minted them.
EntryBranchTarget
A terminator branches to the entry block. Execution enters at the entry, so it must have no predecessors; route the edge to a fresh block instead.
ArgCountMismatch
A jump or branch passes the wrong number of arguments for the target block’s parameters. Pass exactly one argument per target parameter.
Fields
TypeMismatch
A value was used where a different type was required — mismatched binary operands, a non-boolean branch condition, a return value of the wrong type, or a block argument that does not match the target parameter. Fix the lowering so the value’s type matches the position it is used in.
Fields
NotNumeric
An arithmetic operation was applied to a non-numeric value. Add, subtract,
multiply, divide, negate, and the ordering comparisons require
Int or Float operands.
ReturnValueExpected
A return with no value was used in a function whose return type is not
Unit. Return a value of the declared type.
UseBeforeDef
A value was used before its definition reaches the use — its defining block does not dominate the use, or it is used earlier in the block than it is defined. In SSA every use must be dominated by its single definition.
InconsistentDefinition
A value’s recorded definition is inconsistent with the block that lists it:
the value is listed in a block other than the one it records as its
definition site, or it is listed as a parameter while it records an
instruction result (or the reverse). The Builder never
produces this; it can only arise from a hand-assembled or corrupt
deserialized function.
Trait Implementations§
Source§impl Clone for ValidationError
impl Clone for ValidationError
Source§fn clone(&self) -> ValidationError
fn clone(&self) -> ValidationError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ValidationError
impl Debug for ValidationError
Source§impl<'de> Deserialize<'de> for ValidationError
impl<'de> Deserialize<'de> for ValidationError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for ValidationError
impl Display for ValidationError
Source§impl Error for ValidationError
impl Error for ValidationError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl PartialEq for ValidationError
impl PartialEq for ValidationError
Source§fn eq(&self, other: &ValidationError) -> bool
fn eq(&self, other: &ValidationError) -> bool
self and other values to be equal, and is used by ==.