#[non_exhaustive]pub enum OptError {
Module(ModuleError),
InvalidInput {
func: FuncId,
error: ValidationError,
},
InvalidOutput {
func: FuncId,
pass: PassKind,
error: ValidationError,
},
Build {
func: FuncId,
pass: PassKind,
error: BuildError,
},
}Expand description
Why optimization stopped.
Optimizing a valid function never fails: OptError::InvalidInput means
the IR handed in was not valid (nothing was changed), and the other variants
mean a pass produced IR the validator rejects, which is a defect in this crate
(please report it with the input). A function that runs out of
budget is not an error: it is left valid, partly optimized,
and counted in Stats::budget_exhausted.
§Examples
use ir_lang::{FuncId, Module};
use opt_lang::OptError;
let mut m = Module::new("m");
let err = opt_lang::Optimizer::new()
.run_function(&mut m, FuncId::from_u32(3))
.unwrap_err();
assert!(matches!(err, OptError::Module(_)));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Module(ModuleError)
The function is unknown or has no body.
InvalidInput
The function did not validate before optimization; it was left untouched.
InvalidOutput
A pass left the function invalid (a defect in this crate). Reported only when validation between passes is on, which it is by default in debug builds and tests.
Fields
error: ValidationErrorWhat the validator reported.
Build
The IR builder refused a rewrite a pass attempted (a defect in this crate). The function may be partly rewritten.
Trait Implementations§
impl Eq for OptError
Source§impl Error for OptError
impl Error for OptError
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()