#[non_exhaustive]pub enum BuildError {
Show 17 variants
UnboundLabel {
func: FuncId,
label: u32,
},
LabelRebound {
func: FuncId,
label: u32,
},
ForeignLabel {
func: FuncId,
},
TargetOutOfRange {
func: FuncId,
target: u32,
},
InvalidRange {
func: FuncId,
},
TooMany {
func: FuncId,
what: &'static str,
},
UnknownRegister {
func: FuncId,
reg: Reg,
},
PromoteNotDynamic {
func: FuncId,
pc: u32,
},
ConflictingMoves {
func: FuncId,
dst: Reg,
},
InvalidParams {
owner: Callee,
error: ParamError,
},
InvalidShape {
func: FuncId,
error: ShapeError,
},
ForeignFunction(FuncId),
UndefinedFunction(FuncId),
UndefinedType(TypeId),
ConstForwardRef(ConstId),
ModuleFull(&'static str),
TooLarge {
section: u32,
},
}Expand description
Why a function or module could not be built.
§Examples
use bytecode_lang::{BuildError, ModuleBuilder};
let mut m = ModuleBuilder::new();
let mut f = m.function("f", &[], &[]);
let nowhere = f.label();
f.jmp(nowhere); // never bound
let err = m.add_function(f).unwrap_err();
assert!(matches!(err, BuildError::UnboundLabel { .. }));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
UnboundLabel
A branch, table, handler, or local uses a label that was never bound.
LabelRebound
A label was bound twice.
ForeignLabel
A label made by another function’s builder was used.
TargetOutOfRange
A branch target is not an instruction of the function: an emitted instruction names a target past the end, or a label used by a branch is bound after the last instruction.
InvalidRange
A try region or local range ends before it starts.
TooMany
A per-function table is full: registers, captures, name refs, or
type refs (65,536 each), parameters (255), or instructions, jump
tables, handlers (u32::MAX).
UnknownRegister
A register was named that the function never declared.
PromoteNotDynamic
An instruction with overflow = promote writes a register declared
with a static type. promote produces an f64 where an integer does
not fit, so its result must be dyn (OPS §2).
ConflictingMoves
Two moves of one parallel move write the same register.
InvalidParams
A function’s or an import’s ParamList breaks a rule of its own
or does not fit its signature.
InvalidShape
A CallShape is malformed.
ForeignFunction(FuncId)
A function builder does not belong to this module builder, or was already added.
UndefinedFunction(FuncId)
A declared function was never added.
UndefinedType(TypeId)
A reserved type was never defined.
ConstForwardRef(ConstId)
An aggregate constant refers to itself or a later constant.
ModuleFull(&'static str)
A module-level table would pass u32::MAX entries or bytes
(what names it).
TooLarge
An encoded section would exceed 4 GiB, which its length field cannot express.
Trait Implementations§
Source§impl Clone for BuildError
impl Clone for BuildError
impl Copy for BuildError
Source§impl Debug for BuildError
impl Debug for BuildError
Source§impl Display for BuildError
impl Display for BuildError
impl Eq for BuildError
Source§impl Error for BuildError
impl Error for BuildError
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()