#[non_exhaustive]pub enum CodegenError {
InvalidIr(ValidationError),
}Expand description
The reason a Backend could not lower a function.
Lowering needs well-formed SSA: every value defined before it is used, every branch
targeting a real block with arguments that match its parameters, every operation
applied to operands of the right type. A backend checks that up front with
Function::validate and refuses to emit code for
input that fails, rather than producing a program that is wrong in a way the IR
already forbids.
The set is #[non_exhaustive]: a backend that performs target-specific checks may
report failures the bytecode backend never does, so a match on this type must
include a wildcard arm.
§Examples
use codegen_lang::{compile, CodegenError};
use ir_lang::{Builder, Type};
// A function whose entry block never receives a terminator is not well-formed.
let func = Builder::new("f", &[], Type::Unit).finish();
match compile(&func) {
Err(CodegenError::InvalidIr(reason)) => {
assert!(reason.to_string().contains("terminator"));
}
other => panic!("expected an InvalidIr error, got {other:?}"),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
InvalidIr(ValidationError)
The input function did not pass
Function::validate. The wrapped
ValidationError names the offending block or value and explains the
violation; fix the lowering that produced the IR and try again.
Trait Implementations§
Source§impl Clone for CodegenError
impl Clone for CodegenError
Source§fn clone(&self) -> CodegenError
fn clone(&self) -> CodegenError
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 CodegenError
impl Debug for CodegenError
Source§impl<'de> Deserialize<'de> for CodegenError
impl<'de> Deserialize<'de> for CodegenError
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 CodegenError
impl Display for CodegenError
Source§impl Error for CodegenError
impl Error for CodegenError
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 From<ValidationError> for CodegenError
impl From<ValidationError> for CodegenError
Source§fn from(reason: ValidationError) -> Self
fn from(reason: ValidationError) -> Self
Source§impl PartialEq for CodegenError
impl PartialEq for CodegenError
Source§fn eq(&self, other: &CodegenError) -> bool
fn eq(&self, other: &CodegenError) -> bool
self and other values to be equal, and is used by ==.