#[non_exhaustive]
pub enum SyntaxError {
Show 63 variants UnclosedParen { opening_location: Location, }, InvalidModifier, MultipleModifier, UnclosedSingleQuote { opening_location: Location, }, UnclosedDoubleQuote { opening_location: Location, }, UnclosedParam { opening_location: Location, }, EmptyParam, UnclosedCommandSubstitution { opening_location: Location, }, UnclosedBackquote { opening_location: Location, }, UnclosedArith { opening_location: Location, }, InvalidCommandToken, MissingSeparator, FdOutOfRange, 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,
}
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.
§

UnclosedParen

Fields

§opening_location: Location

A ( lacks a closing ).

§

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.

§

UnclosedSingleQuote

Fields

§opening_location: Location

A single quotation lacks a closing '.

§

UnclosedDoubleQuote

Fields

§opening_location: Location

A double quotation lacks a closing ".

§

UnclosedParam

Fields

§opening_location: Location

A parameter expansion lacks a closing }.

§

EmptyParam

A parameter expansion lacks a name.

§

UnclosedCommandSubstitution

Fields

§opening_location: Location

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

§

UnclosedBackquote

Fields

§opening_location: Location

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

§

UnclosedArith

Fields

§opening_location: Location

An arithmetic expansion lacks a closing )).

§

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.

§

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

Fields

§redir_op_location: Location

A here-document content is missing its delimiter.

§

UnclosedArrayValue

Fields

§opening_location: Location

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

§

UnopenedGrouping

A } appears without a matching {.

§

UnclosedGrouping

Fields

§opening_location: Location

A grouping is not closed.

§

EmptyGrouping

A grouping contains no commands.

§

UnopenedSubshell

A ) appears without a matching (.

§

UnclosedSubshell

Fields

§opening_location: Location

A subshell is not closed.

§

EmptySubshell

A subshell contains no commands.

§

UnopenedLoop

A do appears outside a loop.

§

UnopenedDoClause

A done appears outside a loop.

§

UnclosedDoClause

Fields

§opening_location: Location

A do clause is not closed.

§

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

Fields

§opening_location: Location

A for loop is missing a do clause.

§

UnclosedWhileClause

Fields

§opening_location: Location

A while loop is missing a do clause.

§

EmptyWhileCondition

A while loop’s condition is empty.

§

UnclosedUntilClause

Fields

§opening_location: Location

An until loop is missing a do clause.

§

EmptyUntilCondition

An until loop’s condition is empty.

§

IfMissingThen

Fields

§if_location: Location

An if command is missing the then clause.

§

EmptyIfCondition

An if command’s condition is empty.

§

EmptyIfBody

An if command’s body is empty.

§

ElifMissingThen

Fields

§elif_location: Location

An elif clause is missing the then clause.

§

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

Fields

§opening_location: Location

An if command is not closed.

§

MissingCaseSubject

The case command is missing its subject.

§

InvalidCaseSubject

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

§

MissingIn

Fields

§opening_location: Location

The case command is missing in after the subject.

§

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

The first pattern of a case item is esac.

§

UnopenedCase

An esac or ;; appears outside a case command.

§

UnclosedCase

Fields

§opening_location: Location

A case command is not closed.

§

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.

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 copy of the value. Read more
1.0.0 · 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 Error for SyntaxError

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for SyntaxError

source§

impl StructuralEq for SyntaxError

source§

impl StructuralPartialEq for SyntaxError

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.