#[non_exhaustive]pub enum ProblemKind {
Show 19 variants
SyntaxError,
Unmapped,
Unsupported,
NotAllowedHere {
expected: Context,
},
MissingField {
field: &'static str,
},
AmbiguousChild,
UnknownOperator,
UnknownLabel,
InvalidLiteral,
InvalidEscape,
BadSpan,
MissingHole {
template: TemplateId,
},
ExpansionTooDeep {
template: TemplateId,
},
CannotHoist {
reason: HoistBlocker,
},
AttributeArgument,
MisplacedAttribute,
Hir(HirError),
BreakLevel {
level: u64,
loops: u32,
},
NoReceiver,
}Expand description
What is wrong with one construct.
Every kind except Hir comes from lowering itself; a
Hir problem comes from hir-lang’s lenient validator (a break outside a
loop, a duplicate named argument, an out-of-range literal, …). Either
way the construct became an HIR error form and the rest of the unit was
lowered.
§Examples
use lower_lang::ProblemKind;
assert_eq!(ProblemKind::UnknownLabel.to_string(), "no enclosing loop or block has this label");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SyntaxError
A syntax error node from the parser (already reported by it; listed so a host can tell lowering skipped the region).
Unmapped
A node or token kind the mapping does not describe.
Unsupported
A construct the mapping marks Unsupported.
NotAllowedHere
A construct in a context it cannot appear in (a let used as an
expression, a call used as a type).
MissingField
A required part is missing (half-typed code: if with no condition,
fn with no name).
AmbiguousChild
One child was selected for two fields of a construct (positional
picks alias in half-typed code, such as while { ... } with its
condition missing). The first field keeps it; the later one is left
absent.
UnknownOperator
An operator token with no entry in the operator table for its position.
UnknownLabel
A break or continue whose label no enclosing loop or block has.
InvalidLiteral
A number or character literal that does not decode (bad digits, too large for its radix, an empty or multi-character char literal).
InvalidEscape
An escape sequence the literal’s escape style does not define.
BadSpan
A token’s span does not lie inside the source text (a host bug).
MissingHole
A required hole of a template is absent (the node lacks the part the
template needs, such as a while without its condition).
Fields
template: TemplateIdThe template.
ExpansionTooDeep
A template application nested deeper than
Budget::max_expansion_depth.
Fields
template: TemplateIdThe template that could not be applied.
CannotHoist
A binding that must be function-scoped
(LangPolicy::function_scoped_bindings, or a
hoisted let) but cannot be hoisted; it stays scoped to its construct.
Fields
reason: HoistBlockerWhy.
AttributeArgument
An attribute argument that is neither a literal nor a name (HIR attributes are data); it is left out of the attribute.
MisplacedAttribute
An attribute on a construct that has no HIR node to carry it (a wrapper, a capture, a match arm); it is dropped.
Hir(HirError)
A problem hir-lang’s lenient validator found and repaired.
BreakLevel
A numeric break N / continue N
(BreakLevels::Numeric) whose level
is not a positive integer literal (level is 0), or is larger than
the number of loops around it in its function (loops). The jump is
lowered as an error expression. PHP: “‘break’ operator accepts only
positive integers”, “Cannot ‘break’ 2 levels”.
use lower_lang::ProblemKind;
let p = ProblemKind::BreakLevel { level: 3, loops: 2 };
assert_eq!(p.to_string(), "cannot break or continue 3 levels: only 2 loops enclose it");Fields
NoReceiver
The implicit receiver
(LangPolicy::implicit_receiver,
PHP’s $this) read inside a static closure, or a closure nested in
one, where PHP has no $this (“Using $this when not in object
context”). Lowered as written; the problem keeps the closure from
silently capturing the method’s receiver.