Skip to main content

ParseError

Enum ParseError 

Source
#[non_exhaustive]
pub enum ParseError {
#[non_exhaustive]
Expected { expected: Cow<'static, str>, found: Cow<'static, str>, span: Span, },
#[non_exhaustive]
ExpectedExpression { span: Span, },
#[non_exhaustive]
ExpectedStatement { span: Span, },
#[non_exhaustive]
ExpectedOpenTag { span: Span, },
#[non_exhaustive]
UnterminatedString { span: Span, },
#[non_exhaustive]
ExpectedAfter { expected: Cow<'static, str>, after: Cow<'static, str>, span: Span, },
#[non_exhaustive]
UnclosedDelimiter { delimiter: Cow<'static, str>, opened_at: Span, span: Span, },
#[non_exhaustive]
Forbidden { message: Cow<'static, str>, span: Span, },
#[non_exhaustive]
NestingTooDeep { span: Span, },
#[non_exhaustive]
SourceTooLarge { len: usize, span: Span, },
#[non_exhaustive]
VersionTooLow { feature: Cow<'static, str>, required: PhpVersion, used: PhpVersion, span: Span, }, }
Expand description

A parse error or diagnostic emitted during parsing.

The parser recovers from all errors and always produces a complete AST, so errors are informational rather than fatal. Each variant carries a Span identifying the source location.

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

#[non_exhaustive]
Expected

A specific token was expected but a different one was found.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§expected: Cow<'static, str>

Description of the expected token.

§found: Cow<'static, str>

Description of the token actually found, e.g. "';'" or "identifier". A description rather than the lexer’s token kind, so that new tokens are not a breaking change for this type.

§span: Span

Source range of the error.

§

#[non_exhaustive]
ExpectedExpression

An expression was expected but not found (e.g. empty parentheses).

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§span: Span

Source range of the error.

§

#[non_exhaustive]
ExpectedStatement

A statement was expected but not found.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§span: Span

Source range of the error.

§

#[non_exhaustive]
ExpectedOpenTag

PHP source must start with <?php or <?.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§span: Span

Source range of the error.

§

#[non_exhaustive]
UnterminatedString

A string literal was opened but never closed.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§span: Span

Source range of the error.

§

#[non_exhaustive]
ExpectedAfter

A required token was missing after another construct.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§expected: Cow<'static, str>

Description of the expected token.

§after: Cow<'static, str>

Construct the token should follow.

§span: Span

Source range of the error.

§

#[non_exhaustive]
UnclosedDelimiter

A delimiter (parenthesis, bracket, brace) was opened but never closed.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§delimiter: Cow<'static, str>

The expected closing delimiter, e.g. "')'".

§opened_at: Span

Where the delimiter was opened.

§span: Span

Source range of the error.

§

#[non_exhaustive]
Forbidden

A construct that is syntactically valid but semantically forbidden (e.g. (unset) cast, deprecated syntax). Equivalent to a PHP fatal.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§message: Cow<'static, str>

Error message.

§span: Span

Source range of the error.

§

#[non_exhaustive]
NestingTooDeep

Statements, expressions or string interpolations are nested deeper than the parser’s recursion budget. The innermost construct is replaced by an error node so that parsing stays within a bounded stack.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§span: Span

Source range of the error.

§

#[non_exhaustive]
SourceTooLarge

The source is larger than 4 GiB, so byte offsets no longer fit in a Span. Nothing is parsed and the program is empty.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§len: usize

Length of the rejected source in bytes.

§span: Span

Always empty (0..0).

§

#[non_exhaustive]
VersionTooLow

Syntax that requires a newer PHP version than the targeted one. Emitted by crate::parse_with when the source uses features unavailable in the specified crate::PhpVersion.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§feature: Cow<'static, str>

Name of the feature used.

§required: PhpVersion

Minimum PHP version required.

§used: PhpVersion

PHP version targeted.

§span: Span

Source range of the error.

Implementations§

Source§

impl ParseError

Source

pub fn span(&self) -> Span

Source range of the error.

Trait Implementations§

Source§

impl Clone for ParseError

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 ParseError

Source§

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

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

impl Display for ParseError

Source§

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

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

impl Error for ParseError

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

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.