#[non_exhaustive]pub enum ModuleError {
Show 14 variants
DuplicateName {
name: String,
},
EmptyName,
UnknownFunction {
func: FuncId,
},
UnknownGlobal {
global: GlobalId,
},
UnknownAggregate {
agg: AggId,
},
AggregateTooLarge,
BadAlignment {
align: u64,
},
InitSizeMismatch {
size: u64,
found: u64,
},
RelocOutOfRange {
offset: u64,
},
ImportWithData,
CannotDefineImport {
func: FuncId,
},
AlreadyDefined {
func: FuncId,
},
NotDefined {
func: FuncId,
},
CapacityExceeded,
}Expand description
Why a module-level declaration was refused.
Every variant names what was wrong, so a front end can report it against its own
source. The enum is #[non_exhaustive].
§Examples
use ir_lang::{Linkage, Module, ModuleError, Signature};
let mut m = Module::new("m");
let sig = Signature::new(&[], &[]);
m.declare_function("f", &sig, Linkage::Export)?;
let err = m.declare_function("f", &sig, Linkage::Export).unwrap_err();
assert_eq!(err, ModuleError::DuplicateName { name: "f".into() });Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
DuplicateName
A function or global with this name already exists. Symbol names are one namespace per module.
EmptyName
A symbol name was empty.
UnknownFunction
The function handle does not name a declaration of this module.
UnknownGlobal
The global handle does not name a declaration of this module.
UnknownAggregate
An aggregate names an aggregate that is not declared before it.
AggregateTooLarge
An aggregate’s size exceeds MAX_AGGREGATE_SIZE.
BadAlignment
An alignment is zero, not a power of two, or larger than allowed.
InitSizeMismatch
A global’s initializer length differs from its declared size.
RelocOutOfRange
A relocation does not fit inside its global (offset + pointer size > size).
ImportWithData
An imported global was given an initializer or relocations.
CannotDefineImport
An imported function cannot have a body.
AlreadyDefined
The function already has a body (use Module::edit to change it).
NotDefined
The function has no body yet (use Module::build to create one).
CapacityExceeded
A table of the module reached its capacity (u32::MAX - 1 entries).
Trait Implementations§
Source§impl Clone for ModuleError
impl Clone for ModuleError
Source§impl Debug for ModuleError
impl Debug for ModuleError
Source§impl Display for ModuleError
impl Display for ModuleError
impl Eq for ModuleError
Source§impl Error for ModuleError
impl Error for ModuleError
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()