Skip to main content

ProblemKind

Enum ProblemKind 

Source
#[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
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.
§

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

Fields

§expected: Context

What was expected there.

§

MissingField

A required part is missing (half-typed code: if with no condition, fn with no name).

Fields

§field: &'static str

The archetype field.

§

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: TemplateId

The template.

§

ExpansionTooDeep

A template application nested deeper than Budget::max_expansion_depth.

Fields

§template: TemplateId

The 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: HoistBlocker

Why.

§

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

§level: u64

The level written (0: not a positive integer literal; levels beyond u64 saturate).

§loops: u32

The loops around the jump in its function.

§

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.

Trait Implementations§

Source§

impl Clone for ProblemKind

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 ProblemKind

Source§

impl Debug for ProblemKind

Source§

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

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

impl Display for ProblemKind

Source§

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

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

impl Eq for ProblemKind

Source§

impl PartialEq for ProblemKind

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 ProblemKind

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.