Skip to main content

SyntaxError

Enum SyntaxError 

Source
#[non_exhaustive]
pub enum SyntaxError {
Show 80 variants IncompleteEscape, InvalidEscape, UnclosedParen { opening_location: Location, }, UnclosedSingleQuote { opening_location: Location, }, UnclosedDoubleQuote { opening_location: Location, }, UnclosedDollarSingleQuote { opening_location: Location, }, UnclosedParam { opening_location: Location, }, EmptyParam, InvalidParam, InvalidModifier, MultipleModifier, UnclosedCommandSubstitution { opening_location: Location, }, UnclosedBackquote { opening_location: Location, }, UnclosedArith { opening_location: Location, }, InvalidCommandToken, MissingSeparator, FdOutOfRange, InvalidIoLocation, MissingRedirOperand, MissingHereDocDelimiter, MissingHereDocContent, UnclosedHereDocContent { redir_op_location: Location, }, UnclosedArrayValue { opening_location: Location, }, UnopenedGrouping, UnclosedGrouping { opening_location: Location, }, EmptyGrouping, UnopenedSubshell, UnclosedSubshell { opening_location: Location, }, EmptySubshell, UnopenedLoop, UnopenedDoClause, UnclosedDoClause { opening_location: Location, }, EmptyDoClause, MissingForName, InvalidForName, InvalidForValue, MissingForBody { opening_location: Location, }, UnclosedWhileClause { opening_location: Location, }, EmptyWhileCondition, UnclosedUntilClause { opening_location: Location, }, EmptyUntilCondition, IfMissingThen { if_location: Location, }, EmptyIfCondition, EmptyIfBody, ElifMissingThen { elif_location: Location, }, EmptyElifCondition, EmptyElifBody, EmptyElse, UnopenedIf, UnclosedIf { opening_location: Location, }, MissingCaseSubject, InvalidCaseSubject, MissingIn { opening_location: Location, }, UnclosedPatternList, MissingPattern, InvalidPattern, EsacAsPattern, UnopenedCase, UnclosedCase { opening_location: Location, }, UnmatchedParenthesis, MissingFunctionBody, InvalidFunctionBody, InAsCommandName, MissingPipeline(AndOr), DoubleNegation, BangAfterBar, MissingCommandAfterBang, MissingCommandAfterBar, RedundantToken, IncompleteControlEscape, IncompleteControlBackslashEscape, InvalidControlEscape, OctalEscapeOutOfRange, IncompleteHexEscape, IncompleteShortUnicodeEscape, IncompleteLongUnicodeEscape, UnicodeEscapeOutOfRange, UnsupportedFunctionDefinitionSyntax, UnsupportedDoubleBracketCommand, UnsupportedProcessRedirection,
}
Expand description

Types of syntax errors

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

IncompleteEscape

A backslash is at the end of the input.

§

InvalidEscape

A backslash is not followed by a character that makes a valid escape.

§

UnclosedParen

A ( lacks a closing ).

Fields

§opening_location: Location
§

UnclosedSingleQuote

A single quotation lacks a closing '.

Fields

§opening_location: Location
§

UnclosedDoubleQuote

A double quotation lacks a closing ".

Fields

§opening_location: Location
§

UnclosedDollarSingleQuote

A $' lacks a closing '.

Fields

§opening_location: Location
§

UnclosedParam

A parameter expansion lacks a closing }.

Fields

§opening_location: Location
§

EmptyParam

A parameter expansion lacks a name.

§

InvalidParam

A parameter expansion has an invalid name.

§

InvalidModifier

A modifier does not have a valid form in a parameter expansion.

§

MultipleModifier

A braced parameter expansion has both a prefix and suffix modifier.

§

UnclosedCommandSubstitution

A command substitution started with $( but lacks a closing ).

Fields

§opening_location: Location
§

UnclosedBackquote

A command substitution started with ` but lacks a closing `.

Fields

§opening_location: Location
§

UnclosedArith

An arithmetic expansion lacks a closing )).

Fields

§opening_location: Location
§

InvalidCommandToken

A command begins with an inappropriate keyword or operator token.

§

MissingSeparator

A separator is missing between commands.

§

FdOutOfRange

The file descriptor specified for a redirection cannot be used.

§

InvalidIoLocation

An I/O location prefix attached to a redirection has an unsupported format.

§

MissingRedirOperand

A redirection operator is missing its operand.

§

MissingHereDocDelimiter

A here-document operator is missing its delimiter token.

§

MissingHereDocContent

A here-document operator is missing its corresponding content.

§

UnclosedHereDocContent

A here-document content is missing its delimiter.

Fields

§redir_op_location: Location
§

UnclosedArrayValue

An array assignment started with =( but lacks a closing ).

Fields

§opening_location: Location
§

UnopenedGrouping

A } appears without a matching {.

§

UnclosedGrouping

A grouping is not closed.

Fields

§opening_location: Location
§

EmptyGrouping

A grouping contains no commands.

§

UnopenedSubshell

A ) appears without a matching (.

§

UnclosedSubshell

A subshell is not closed.

Fields

§opening_location: Location
§

EmptySubshell

A subshell contains no commands.

§

UnopenedLoop

A do appears outside a loop.

§

UnopenedDoClause

A done appears outside a loop.

§

UnclosedDoClause

A do clause is not closed.

Fields

§opening_location: Location
§

EmptyDoClause

A do clause contains no commands.

§

MissingForName

The variable name is missing in a for loop.

§

InvalidForName

The variable name is not a valid word in a for loop.

§

InvalidForValue

A value is not a valid word in a for loop.

§

MissingForBody

A for loop is missing a do clause.

Fields

§opening_location: Location
§

UnclosedWhileClause

A while loop is missing a do clause.

Fields

§opening_location: Location
§

EmptyWhileCondition

A while loop’s condition is empty.

§

UnclosedUntilClause

An until loop is missing a do clause.

Fields

§opening_location: Location
§

EmptyUntilCondition

An until loop’s condition is empty.

§

IfMissingThen

An if command is missing the then clause.

Fields

§if_location: Location
§

EmptyIfCondition

An if command’s condition is empty.

§

EmptyIfBody

An if command’s body is empty.

§

ElifMissingThen

An elif clause is missing the then clause.

Fields

§elif_location: Location
§

EmptyElifCondition

An elif clause’s condition is empty.

§

EmptyElifBody

An elif clause’s body is empty.

§

EmptyElse

An else clause is empty.

§

UnopenedIf

An elif, else, then, or fi appears outside an if command.

§

UnclosedIf

An if command is not closed.

Fields

§opening_location: Location
§

MissingCaseSubject

The case command is missing its subject.

§

InvalidCaseSubject

The subject of the case command is not a valid word.

§

MissingIn

The case command is missing in after the subject.

Fields

§opening_location: Location
§

UnclosedPatternList

The ) is missing in a case item.

§

MissingPattern

The pattern is missing in a case item.

§

InvalidPattern

The pattern is not a valid word token.

§

EsacAsPattern

👎Deprecated since 0.12.1:

this error no longer occurs

The first pattern of a case item is esac.

§

UnopenedCase

An esac or ;; appears outside a case command.

§

UnclosedCase

A case command is not closed.

Fields

§opening_location: Location
§

UnmatchedParenthesis

The ( is not followed by ) in a function definition.

§

MissingFunctionBody

The function body is missing in a function definition command.

§

InvalidFunctionBody

A function body is not a compound command.

§

InAsCommandName

The keyword in is used as a command name.

§

MissingPipeline(AndOr)

A pipeline is missing after a && or || token.

§

DoubleNegation

Two successive ! tokens.

§

BangAfterBar

A | token is followed by a !.

§

MissingCommandAfterBang

A command is missing after a ! token.

§

MissingCommandAfterBar

A command is missing after a | token.

§

RedundantToken

There is a redundant token.

§

IncompleteControlEscape

A control escape (\c...) is incomplete in a dollar-single-quoted string.

§

IncompleteControlBackslashEscape

A control-backslash escape (\c\\) is incomplete in a dollar-single-quoted string.

§

InvalidControlEscape

A control escape (\c...) does not have a valid control character.

§

OctalEscapeOutOfRange

An octal escape is out of range (greater than \377) in a dollar-single-quoted string.

§

IncompleteHexEscape

An hexadecimal escape (\x...) is incomplete in a dollar-single-quoted string.

§

IncompleteShortUnicodeEscape

A Unicode escape (\u...) is incomplete in a dollar-single-quoted string.

§

IncompleteLongUnicodeEscape

A Unicode escape (\U...) is incomplete in a dollar-single-quoted string.

§

UnicodeEscapeOutOfRange

A Unicode escape (\u... or \U...) is out of range in a dollar-single-quoted string.

§

UnsupportedFunctionDefinitionSyntax

The unsupported version of function definition syntax is used.

§

UnsupportedDoubleBracketCommand

A [[ ... ]] command is used.

§

UnsupportedProcessRedirection

A process redirection (>(...) or <(...)) is used.

Implementations§

Source§

impl SyntaxError

Source

pub fn message(&self) -> &'static str

Returns an error message describing the error.

Source

pub fn label(&self) -> &'static str

Returns a label for annotating the error location.

Source

pub fn related_location(&self) -> Option<(&Location, &'static str)>

Returns a location related with the error cause and a message describing the location.

Trait Implementations§

Source§

impl Clone for SyntaxError

Source§

fn clone(&self) -> SyntaxError

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 SyntaxError

Source§

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

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

impl Display for SyntaxError

Source§

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

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

impl Eq for SyntaxError

Source§

impl Error for SyntaxError

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

impl From<SyntaxError> for ErrorCause

Source§

fn from(source: SyntaxError) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for SyntaxError

Source§

fn eq(&self, other: &SyntaxError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SyntaxError

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> 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<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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.