Skip to main content

MappingError

Enum MappingError 

Source
#[non_exhaustive]
pub enum MappingError { MissingField { rule: usize, field: &'static str, }, DuplicateKind { table: &'static str, index: usize, }, DuplicateTypeName { index: usize, }, UnknownTemplate { template: usize, }, HoleCount { rule: usize, expected: usize, found: usize, }, ApplyArgs { template: usize, }, BadOperator { fixity: Fixity, index: usize, }, TooLarge, BadJoin { rule: usize, }, EmptyOperatorText { fixity: Fixity, index: usize, }, UnknownArchetype { index: usize, }, UnknownName { index: usize, }, }
Expand description

Why a mapping was refused.

§Examples

use lower_lang::{Arch, MappingBuilder, MappingError, Pick};

let mut b = MappingBuilder::<u8>::new();
b.node(1, Arch::If { cond: Pick::Absent, then: Pick::Nth(1), else_: Pick::Absent });
assert_eq!(b.build().unwrap_err(), MappingError::MissingField { rule: 0, field: "cond" });

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

MissingField

Rule rule (in registration order) leaves a required field Absent.

Fields

§rule: usize

The rule’s registration index.

§field: &'static str

The field.

§

DuplicateKind

A kind has two entries in a table that allows one (table names it: “token role”, “modifier”, “root”, “prefix operator”, …).

Fields

§table: &'static str

The table.

§index: usize

The later entry’s registration index in that table.

§

DuplicateTypeName

A type name is registered twice.

Fields

§index: usize

The later entry’s registration index.

§

UnknownTemplate

A template id that this mapping did not issue (or, inside a template, one not registered before it).

Fields

§template: usize

The id’s index.

§

HoleCount

A node binds a template with the wrong number of picks.

Fields

§rule: usize

The rule’s registration index.

§expected: usize

The template’s hole count.

§found: usize

The picks given.

§

ApplyArgs

An apply inside template template passes arguments that do not match the applied template’s holes (count, or kind, or Absent for a required hole).

Fields

§template: usize

The registering template’s index.

§

BadOperator

An operator maps to a spec that cannot apply at its position: an op of the wrong arity, a compound op HIR does not allow, a policy that does not fit its op, assignment outside binary position, identity outside unary position, or a template whose holes are not one expression per operand.

Fields

§fixity: Fixity

The operator’s position.

§index: usize

Its registration index in that table.

§

TooLarge

A table outgrew its index type.

§

BadJoin

Rule rule joins an interpolated string with a template whose holes are neither two expressions nor one argument list.

Fields

§rule: usize

The rule’s registration index.

§

EmptyOperatorText

A text-keyed operator entry has an empty text.

Fields

§fixity: Fixity

The operator’s position.

§index: usize

Its registration index in the text table.

§

UnknownArchetype

A per-archetype modifier entry (modifier_in) names no archetype (Arch::lsf_name lists the names).

Fields

§index: usize

Its registration index among the per-archetype modifiers.

§

UnknownName

LangPolicy::implicit_receiver is a NameRef this builder did not issue.

Fields

§index: usize

The name’s index.

Trait Implementations§

Source§

impl Clone for MappingError

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 MappingError

Source§

impl Debug for MappingError

Source§

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

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

impl Display for MappingError

Source§

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

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

impl Eq for MappingError

Source§

impl Error for MappingError

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 PartialEq for MappingError

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 MappingError

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.