#[non_exhaustive]pub enum CompileError {
Show 14 variants
Unsupported {
feature: Unsupported,
node: NodeRef,
span: Span,
},
Unresolved {
node: NodeRef,
span: Span,
},
ErrorNode {
node: NodeRef,
span: Span,
},
LiteralOutOfRange {
node: NodeRef,
span: Span,
},
NotAssignable {
node: NodeRef,
span: Span,
},
UnknownIntrinsic {
name: Symbol,
node: NodeRef,
span: Span,
},
IntrinsicArity {
node: NodeRef,
span: Span,
arity: Arity,
found: u32,
},
TooManyArgs {
node: NodeRef,
span: Span,
limit: u32,
},
TooManyParams {
node: NodeRef,
span: Span,
limit: u32,
},
TooManyJumps {
node: NodeRef,
span: Span,
},
Class {
problem: ClassProblem,
node: NodeRef,
span: Span,
},
InvalidOption {
option: &'static str,
},
BudgetExceeded {
limit: u64,
},
Build(BuildError),
}Expand description
Why compile refused a unit.
Errors about the program name the HIR node and its source span, so a front end can point at the offending code. Compilation stops at the first error, in the canonical order of the unit.
§Examples
use bcgen_lang::CompileError;
use hir_lang::{Builder, Effects, Expr, Item, ItemKind, List};
use intern_lang::Interner;
// A module whose body failed to lower: it was reported already, so it
// does not compile.
let mut b = Builder::new();
let body = b.expr(Expr::Err);
let module = ItemKind::Module { items: List::EMPTY, body: Some(body), effects: Effects::NONE };
let root = b.item(Item::new(None, module));
let hir = b.finish(root)?;
let err = bcgen_lang::compile(&hir, &Interner::new()).unwrap_err();
assert!(matches!(err, CompileError::ErrorNode { .. }));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Unsupported
A form this release does not compile.
Unresolved
A path the resolver left unresolved (or resolved to Res::Err): the
compiler runs on resolved HIR.
ErrorNode
An error node (Expr::Err, Stmt::Err, …) from lenient lowering:
broken source was reported already and does not compile.
LiteralOutOfRange
An integer literal outside the dynamic integer range (i64).
NotAssignable
An assignment target that is not a writable place (a function, a constant, an append read).
UnknownIntrinsic
A named intrinsic the Intrinsics table does
not have.
Fields
IntrinsicArity
A named intrinsic called with a number of operands its table entry does not accept.
Fields
TooManyArgs
A call with more arguments than an LSB call window carries (255, counting a method’s receiver).
TooManyParams
A function or closure with more parameters than an LSB parameter list carries: 64 when a parameter has a default (the width of the presence mask), else 255 (including a generator closure’s captures).
TooManyJumps
A finally (or defer) left by more distinct jump targets than its
i8 completion kind can number (124).
Class
A class graph or member the module cannot hold (see
ClassProblem); node is the class or member.
InvalidOption
An option names something the compiler cannot use: option is the
option’s name (string_offsets: the intrinsic is not in the table or
does not take two operands).
BudgetExceeded
The instruction budget (Options::with_max_instructions) ran out.
Build(BuildError)
The LSB builder refused the module: a format limit (65,536 registers in one function, 4 GiB in one section, …).
Implementations§
Trait Implementations§
Source§impl Clone for CompileError
impl Clone for CompileError
impl Copy for CompileError
Source§impl Debug for CompileError
impl Debug for CompileError
Source§impl Display for CompileError
impl Display for CompileError
impl Eq for CompileError
Source§impl Error for CompileError
impl Error for CompileError
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()