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;RegionNotFoundis reported asflm.lowering.region-not-foundinstead, andRefusedreports the rule’s own diagnostic. The node then lowers to a childlessflm.pres.unsupportedstand-in, as an element the backend cannot render does, and the rest of the tree lowers normally. Buildfails the lowering of the whole tree, with oneflm.lowering.faileddiagnostic; the tree then has no lowered form.PlaceholderCharactersis 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
element: ElementNameThe 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.
Build
Building a node failed inside the parser toolkit (techy). The rule cannot recover from it, and the lowering of the whole tree fails.
CatchUp
A synthesized value could not be brought up to date (value
catch-up), so it could
not be spliced; see Lowerer::splice.
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
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.
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.
Implementations§
Source§impl LowerError
impl LowerError
Trait Implementations§
Source§impl Clone for LowerError
impl Clone for LowerError
Source§impl Debug for LowerError
impl Debug for LowerError
Source§impl Display for LowerError
impl Display for LowerError
Source§impl Error for LowerError
impl Error for LowerError
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()
Source§impl From<AccessError> for LowerError
impl From<AccessError> for LowerError
Source§fn from(error: AccessError) -> LowerError
fn from(error: AccessError) -> LowerError
Source§impl From<OptionError> for LowerError
impl From<OptionError> for LowerError
Source§fn from(error: OptionError) -> LowerError
fn from(error: OptionError) -> LowerError
Auto Trait Implementations§
impl !RefUnwindSafe for LowerError
impl !UnwindSafe for LowerError
impl Forget for LowerError
impl Freeze for LowerErrorwhere
*const ArcInner<str> is !null: Freeze,
PhantomData<ArcInner<str>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<CapName>: Freeze,
&'static str: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<ElementName>: Freeze,
*const Diagnostic<FlmOrigin> is !null: Freeze,
PhantomData<Diagnostic<FlmOrigin>>: Freeze,
impl Move for LowerError
impl Send for LowerError
impl Sync for LowerError
impl Unpin for LowerError
impl UnsafeUnpin for LowerErrorwhere
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<CapName>: UnsafeUnpin,
&'static str: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<ElementName>: UnsafeUnpin,
*const Diagnostic<FlmOrigin> is !null: UnsafeUnpin,
PhantomData<Diagnostic<FlmOrigin>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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