Skip to main content

CompileError

Enum CompileError 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Unsupported

A form this release does not compile.

Fields

§feature: Unsupported

What is missing.

§node: NodeRef

The node.

§span: Span

Its source span.

§

Unresolved

A path the resolver left unresolved (or resolved to Res::Err): the compiler runs on resolved HIR.

Fields

§node: NodeRef

The path’s node.

§span: Span

Its source span.

§

ErrorNode

An error node (Expr::Err, Stmt::Err, …) from lenient lowering: broken source was reported already and does not compile.

Fields

§node: NodeRef

The node.

§span: Span

Its source span.

§

LiteralOutOfRange

An integer literal outside the dynamic integer range (i64).

Fields

§node: NodeRef

The literal’s node.

§span: Span

Its source span.

§

NotAssignable

An assignment target that is not a writable place (a function, a constant, an append read).

Fields

§node: NodeRef

The target’s node.

§span: Span

Its source span.

§

UnknownIntrinsic

A named intrinsic the Intrinsics table does not have.

Fields

§name: Symbol

The intrinsic’s name.

§node: NodeRef

The intrinsic’s node.

§span: Span

Its source span.

§

IntrinsicArity

A named intrinsic called with a number of operands its table entry does not accept.

Fields

§node: NodeRef

The intrinsic’s node.

§span: Span

Its source span.

§arity: Arity

The operands it takes.

§found: u32

The operands it was given.

§

TooManyArgs

A call with more arguments than an LSB call window carries (255, counting a method’s receiver).

Fields

§node: NodeRef

The call.

§span: Span

Its source span.

§limit: u32

The limit.

§

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).

Fields

§node: NodeRef

The function or closure.

§span: Span

Its source span.

§limit: u32

The limit.

§

TooManyJumps

A finally (or defer) left by more distinct jump targets than its i8 completion kind can number (124).

Fields

§node: NodeRef

The try or defer.

§span: Span

Its source span.

§

Class

A class graph or member the module cannot hold (see ClassProblem); node is the class or member.

Fields

§problem: ClassProblem

What is wrong.

§node: NodeRef

The class or member.

§span: Span

Its span.

§

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).

Fields

§option: &'static str

The option.

§

BudgetExceeded

The instruction budget (Options::with_max_instructions) ran out.

Fields

§limit: u64

The budget, in instructions.

§

Build(BuildError)

The LSB builder refused the module: a format limit (65,536 registers in one function, 4 GiB in one section, …).

Implementations§

Source§

impl CompileError

Source

pub const fn node(&self) -> Option<NodeRef>

The node the error is about, when it is about one.

§Examples
use bcgen_lang::CompileError;

assert_eq!(CompileError::BudgetExceeded { limit: 1 }.node(), None);
Source

pub const fn span(&self) -> Option<Span>

The source span of the node the error is about, when there is one.

§Examples
use bcgen_lang::CompileError;

assert_eq!(CompileError::BudgetExceeded { limit: 1 }.span(), None);

Trait Implementations§

Source§

impl Clone for CompileError

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for CompileError

Source§

impl Debug for CompileError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for CompileError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for CompileError

Source§

impl Error for CompileError

1.30.0 · Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<BuildError> for CompileError

Source§

fn from(e: BuildError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for CompileError

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CompileError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.