pub struct ValidationError { /* private fields */ }Expand description
Why a module is not well-formed: what is wrong, and where.
Module::validate returns the first problem it finds
in a fixed order (module declarations, then each function in handle order;
within a function: structure, instructions, terminators, exception edges,
dominance, safepoints).
§Examples
use ir_lang::{Linkage, Module, Signature, Type, ValidationErrorKind};
let mut m = Module::new("m");
let f = m.declare_function("f", &Signature::new(&[], &[Type::I32]), Linkage::Export)?;
// Exported but never given a body.
let err = m.validate().unwrap_err();
assert_eq!(err.func(), Some(f));
assert_eq!(err.kind(), &ValidationErrorKind::MissingBody);Implementations§
Source§impl ValidationError
impl ValidationError
Sourcepub fn func(&self) -> Option<FuncId>
pub fn func(&self) -> Option<FuncId>
The function the problem is in, if it is inside one.
See ValidationError for an example.
Sourcepub fn block(&self) -> Option<Block>
pub fn block(&self) -> Option<Block>
The block the problem is in, if any.
§Examples
use ir_lang::{Linkage, Module, Signature};
let mut m = Module::new("m");
let f = m.declare_function("f", &Signature::new(&[], &[]), Linkage::Export)?;
let _ = m.build(f)?; // the entry block is never terminated
let err = m.validate().unwrap_err();
assert_eq!(err.block().map(|b| b.index()), Some(0));Sourcepub fn inst(&self) -> Option<Inst>
pub fn inst(&self) -> Option<Inst>
The instruction the problem is in, if it is in one (None for a terminator
or a block-level problem).
§Examples
use ir_lang::{Linkage, Module, Signature};
let mut m = Module::new("m");
let f = m.declare_function("f", &Signature::new(&[], &[]), Linkage::Export)?;
let _ = m.build(f)?;
assert_eq!(m.validate().unwrap_err().inst(), None);Sourcepub fn kind(&self) -> &ValidationErrorKind
pub fn kind(&self) -> &ValidationErrorKind
What is wrong.
See ValidationError for an example.
Trait Implementations§
Source§impl Clone for ValidationError
impl Clone for ValidationError
Source§impl Debug for ValidationError
impl Debug for ValidationError
Source§impl Display for ValidationError
impl Display for ValidationError
impl Eq 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)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl PartialEq for ValidationError
impl PartialEq for ValidationError
impl StructuralPartialEq for ValidationError
Auto Trait Implementations§
impl Freeze for ValidationError
impl RefUnwindSafe for ValidationError
impl Send for ValidationError
impl Sync for ValidationError
impl Unpin for ValidationError
impl UnsafeUnpin for ValidationError
impl UnwindSafe for ValidationError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more