Skip to main content

LowerError

Enum LowerError 

Source
pub enum LowerError {
    Access(AccessError),
    Option(OptionError),
    UndeclaredProduces {
        rule: RuleName,
        element: ElementName,
        declared: Vec<ElementName>,
    },
    Structure {
        detail: String,
    },
    Build {
        detail: String,
    },
    CatchUp {
        detail: String,
    },
    DocumentFactInValue {
        stage: StageName,
        table: CapName,
    },
    Refused(Box<FlmDiagnostic>),
    RegionNotFound {
        detail: String,
    },
    PlaceholderCharacters,
    Other {
        detail: String,
    },
}
Expand description

The failure of a lowering rule at one node.

A rule returns this error from Lower::lower, and every Lowerer method that can refuse something returns it too. The lowering stage handles it according to the variant (crate::stdlib::backends::lowering::error lists the conditions):

  • Most variants fail the node only. The stage reports one Error diagnostic at the node, flm.lowering.rule-failed, whose message includes this error’s text; RegionNotFound is reported as flm.lowering.region-not-found instead, and Refused reports the rule’s own diagnostic. The node then lowers to a childless flm.pres.unsupported stand-in, as an element the backend cannot render does, and the rest of the tree lowers normally.
  • Build fails the lowering of the whole tree, with one flm.lowering.failed diagnostic; the tree then has no lowered form.
  • PlaceholderCharacters is not a failure of the node and is not reported: it is passed on to the rule that spliced the template it arose in.

A rule must return every error the Lowerer gives it, rather than continue: after a refused call the Lowerer has staged nothing, and a rule that continues as though it had breaks an invariant of the lowering.

Variants§

§

Access(AccessError)

The rule read a table it did not declare, or read a table as the wrong value type.

The error is the store’s own (AccessError), shared with stages; its stage field holds the rule’s name.

§

Option(OptionError)

The rule read an option type it did not declare. The error’s stage field holds the rule’s name.

§

UndeclaredProduces

The rule tried to build a node of an element that its declaration’s produces does not list.

Fields

§rule: RuleName

The rule that tried.

§element: ElementName

The element of the node it tried to build.

§declared: Vec<ElementName>

The elements the rule’s declaration lists.

§

Structure

The node, or the nodes a rule passed to a Lowerer method, do not have the structure the rule or the method requires: for example, a node without the payload its element always carries, an argument that is absent, or nodes of another tree.

Fields

§detail: String

What was found, as a phrase that completes the error’s message.

§

Build

Building a node failed inside the parser toolkit (techy). The rule cannot recover from it, and the lowering of the whole tree fails.

Fields

§detail: String

The toolkit’s own text for the failure.

§

CatchUp

A synthesized value could not be brought up to date (value catch-up), so it could not be spliced; see Lowerer::splice.

Fields

§detail: String

The text of the failure.

§

DocumentFactInValue

Bringing a synthesized value up to date was refused because a stage, run again over it, stated a fact about the document as a whole, such as a label, which a synthesized value must not do; see Lowerer::splice and value catch-up.

It is a variant of its own, rather than a CatchUp failure, so that a rule splicing a value it built from what an author wrote can tell the author what to change. The user-definitions feature does so for a kept definition whose template declares a reference point (KeptTemplateDeclaresPoint). A rule that returns this error unchanged gets flm.lowering.rule-failed, as for any other failure.

Fields

§stage: StageName

The stage that stated the fact.

§table: CapName

The table in which the fact was stated.

§

Refused(Box<FlmDiagnostic>)

The rule refuses the node for the reason that the carried diagnostic states, in terms the author can act on.

The lowering stage reports that diagnostic instead of flm.lowering.rule-failed, and lowers the node to the same stand-in as for any other failure. It does so at every node the rule refuses: a refusal about something every use shares, such as a user definition, is reported at each use.

§

RegionNotFound

The node region that Lowerer::lower_region was asked to lower does not exist: no tree of that identifier is reachable, the tree holds no node at that address, or the node has no argument or content slot at that position.

The lowering stage reports it at the node whose rule asked, under a condition of its own (flm.lowering.region-not-found) rather than as a rule failure, and that node lowers to the same stand-in as for a rule failure.

Fields

§detail: String

The text saying what could not be found.

§

PlaceholderCharacters

The rule needs the characters of some content (an address, a reference key, verbatim content, or anything computed from them), and the content holds a placeholder of a user definition’s template, whose characters are not known yet. A rule obtains characters through chars_at_lowering, which returns this error for it; a rule that computes on the content as written rather than on its characters gets it from spelling_at_lowering.

Only a template lowered unexpanded, placeholders included, holds a placeholder. The recomposed LaTeX lowers the template of a kept definition this way, once, to write it as a LaTeX definition in which each placeholder is a parameter that LaTeX replaces at every call. A parameter may be placed where the template typesets content, but not where a rule needs characters, since those are known only at a call. So the rule returns this error, and the lowering passes it on, unreported, from rule to rule up to the rule that spliced the template, which acts on it. The user-definitions feature then expands every use site of that definition instead of writing a call. The lists feature, whose recomposed LaTeX lowers a list’s own label template with its number formats written as placeholders, reports a number format placed where characters are read. Wherever a template was expanded (on every other output, and at every expanded use site), no placeholder of a user definition remains, and this error does not occur.

An error of this variant that reaches the lowering of a whole tree fails that tree.

§

Other

Any other failure the rule reports.

Fields

§detail: String

The text of the failure.

Implementations§

Source§

impl LowerError

Source

pub fn structure(detail: impl Into<String>) -> LowerError

Returns a Structure error: the nodes do not have the structure required; detail says what was found.

Source

pub fn other(detail: impl Into<String>) -> LowerError

Returns an Other error described by detail.

Trait Implementations§

Source§

impl Clone for LowerError

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 Debug for LowerError

Source§

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

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

impl Display for LowerError

Source§

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

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

impl Error for LowerError

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

Replaced by Error::source.
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<AccessError> for LowerError

Source§

fn from(error: AccessError) -> LowerError

Converts to this type from the input type.
Source§

impl From<OptionError> for LowerError

Source§

fn from(error: OptionError) -> LowerError

Converts to this type from the input type.

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> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.