#[non_exhaustive]pub enum AotError {
Codegen(CodegenError),
Link(LinkError),
}Expand description
The reason an ahead-of-time compile could not be completed.
A compile runs two stages — lower each function to object code, then link the objects into an image — and either stage can fail. The two variants keep the origin of a failure visible instead of flattening both into one opaque message, and each carries the underlying error so the exact cause can be inspected or reported without guesswork.
AotError implements Display and
core::error::Error, with source set to the
wrapped error, and converts from both underlying errors so ? propagates them
directly. The enum is #[non_exhaustive]: a later stage that reports a new kind
of failure is an additive change, so a match on it must keep a wildcard arm.
§Examples
A malformed function is rejected during lowering, before any linking happens:
use aot_lang::{compile, AotError};
use ir_lang::{Builder, Type};
// Declares an int return but never returns a value.
let func = Builder::new("bad", &[], Type::Int).finish();
assert!(matches!(compile(&func), Err(AotError::Codegen(_))));Inspect the source through the Error trait:
use aot_lang::compile;
use core::error::Error;
use ir_lang::{Builder, Type};
let func = Builder::new("bad", &[], Type::Int).finish();
let err = compile(&func).unwrap_err();
assert!(err.source().is_some());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Codegen(CodegenError)
A function could not be lowered to object code. The wrapped
CodegenError names the offending block or value; the usual cause is IR
that does not pass Function::validate.
Link(LinkError)
The objects could not be linked into an image. The wrapped LinkError
points at the symbol, section, or relocation involved — most often a
duplicate function name or an undefined entry point.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for AotError
impl<'de> Deserialize<'de> for AotError
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 Error for AotError
impl Error for AotError
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()