pub enum TokenType {
Show 105 variants
Eq,
Lt,
Le,
EqEq,
Gt,
AndAnd,
OrOr,
Not,
Tilde,
Plus,
Minus,
Star,
And,
Or,
At,
Dot,
DotDot,
DotDotDot,
DotDotEq,
Comma,
Semi,
Colon,
PathSep,
RArrow,
FatArrow,
Pound,
Question,
OpenParen,
CloseParen,
OpenBrace,
CloseBrace,
OpenBracket,
CloseBracket,
Eof,
Operator,
Ident,
Lifetime,
Path,
Type,
Const,
KwAs,
KwAsync,
KwAuto,
KwAwait,
KwBecome,
KwBox,
KwBreak,
KwCatch,
KwConst,
KwContinue,
KwCrate,
KwDefault,
KwDyn,
KwElse,
KwEnum,
KwExtern,
KwFn,
KwFor,
KwGen,
KwIf,
KwImpl,
KwIn,
KwLet,
KwLoop,
KwMacro,
KwMacroRules,
KwMatch,
KwMod,
KwMove,
KwMut,
KwPub,
KwRaw,
KwRef,
KwReturn,
KwReuse,
KwSafe,
KwSelfUpper,
KwStatic,
KwStruct,
KwTrait,
KwTry,
KwType,
KwUnderscore,
KwUnsafe,
KwUse,
KwWhere,
KwWhile,
KwYield,
SymAttSyntax,
SymClobberAbi,
SymInlateout,
SymInout,
SymIs,
SymLabel,
SymLateout,
SymMayUnwind,
SymNomem,
SymNoreturn,
SymNostack,
SymOptions,
SymOut,
SymPreservesFlags,
SymPure,
SymReadonly,
SymSym,
}
Expand description
Used in “expected”/“expected one of” error messages. Tokens are added here
as necessary. Tokens with values (e.g. literals, identifiers) are
represented by a single variant (e.g. Literal
, Ident
).
It’s an awkward representation, but it’s important for performance. It’s a
C-style parameterless enum so that TokenTypeSet
can be a bitset. This is
important because Parser::expected_token_types
is very hot. TokenType
used to have variants with parameters (e.g. all the keywords were in a
single Keyword
variant with a Symbol
parameter) and
Parser::expected_token_types
was a Vec<TokenType>
which was much slower
to manipulate.
We really want to keep the number of variants to 128 or fewer, so that
TokenTypeSet
can be implemented with a u128
.
Variants§
Eq
Lt
Le
EqEq
Gt
AndAnd
OrOr
Not
Tilde
Plus
Minus
Star
And
Or
At
Dot
DotDot
DotDotDot
DotDotEq
Comma
Semi
Colon
PathSep
RArrow
FatArrow
Pound
Question
OpenParen
CloseParen
OpenBrace
CloseBrace
OpenBracket
CloseBracket
Eof
Operator
Any operator.
Ident
Any identifier token.
Lifetime
Any lifetime token.
Path
Any token that can start a path.
Type
Any token that can start a type.
Const
Any token that can start a const expression.
KwAs
KwAsync
KwAuto
KwAwait
KwBecome
KwBox
KwBreak
KwCatch
KwConst
KwContinue
KwCrate
KwDefault
KwDyn
KwElse
KwEnum
KwExtern
KwFn
KwFor
KwGen
KwIf
KwImpl
KwIn
KwLet
KwLoop
KwMacro
KwMacroRules
KwMatch
KwMod
KwMove
KwMut
KwPub
KwRaw
KwRef
KwReturn
KwReuse
KwSafe
KwSelfUpper
KwStatic
KwStruct
KwTrait
KwTry
KwType
KwUnderscore
KwUnsafe
KwUse
KwWhere
KwWhile
KwYield
SymAttSyntax
SymClobberAbi
SymInlateout
SymInout
SymIs
SymLabel
SymLateout
SymMayUnwind
SymNomem
SymNoreturn
SymNostack
SymOptions
SymOut
SymPreservesFlags
SymPure
SymReadonly
SymSym
Implementations§
Trait Implementations§
impl Copy for TokenType
impl StructuralPartialEq for TokenType
Auto Trait Implementations§
impl DynSend for TokenType
impl DynSync for TokenType
impl Freeze for TokenType
impl RefUnwindSafe for TokenType
impl Send for TokenType
impl Sync for TokenType
impl Unpin for TokenType
impl UnwindSafe for TokenType
Blanket Implementations§
Source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 1 byte
Size for each variant:
Eq
: 0 bytesLt
: 0 bytesLe
: 0 bytesEqEq
: 0 bytesGt
: 0 bytesAndAnd
: 0 bytesOrOr
: 0 bytesNot
: 0 bytesTilde
: 0 bytesPlus
: 0 bytesMinus
: 0 bytesStar
: 0 bytesAnd
: 0 bytesOr
: 0 bytesAt
: 0 bytesDot
: 0 bytesDotDot
: 0 bytesDotDotDot
: 0 bytesDotDotEq
: 0 bytesComma
: 0 bytesSemi
: 0 bytesColon
: 0 bytesPathSep
: 0 bytesRArrow
: 0 bytesFatArrow
: 0 bytesPound
: 0 bytesQuestion
: 0 bytesOpenParen
: 0 bytesCloseParen
: 0 bytesOpenBrace
: 0 bytesCloseBrace
: 0 bytesOpenBracket
: 0 bytesCloseBracket
: 0 bytesEof
: 0 bytesOperator
: 0 bytesIdent
: 0 bytesLifetime
: 0 bytesPath
: 0 bytesType
: 0 bytesConst
: 0 bytesKwAs
: 0 bytesKwAsync
: 0 bytesKwAuto
: 0 bytesKwAwait
: 0 bytesKwBecome
: 0 bytesKwBox
: 0 bytesKwBreak
: 0 bytesKwCatch
: 0 bytesKwConst
: 0 bytesKwContinue
: 0 bytesKwCrate
: 0 bytesKwDefault
: 0 bytesKwDyn
: 0 bytesKwElse
: 0 bytesKwEnum
: 0 bytesKwExtern
: 0 bytesKwFn
: 0 bytesKwFor
: 0 bytesKwGen
: 0 bytesKwIf
: 0 bytesKwImpl
: 0 bytesKwIn
: 0 bytesKwLet
: 0 bytesKwLoop
: 0 bytesKwMacro
: 0 bytesKwMacroRules
: 0 bytesKwMatch
: 0 bytesKwMod
: 0 bytesKwMove
: 0 bytesKwMut
: 0 bytesKwPub
: 0 bytesKwRaw
: 0 bytesKwRef
: 0 bytesKwReturn
: 0 bytesKwReuse
: 0 bytesKwSafe
: 0 bytesKwSelfUpper
: 0 bytesKwStatic
: 0 bytesKwStruct
: 0 bytesKwTrait
: 0 bytesKwTry
: 0 bytesKwType
: 0 bytesKwUnderscore
: 0 bytesKwUnsafe
: 0 bytesKwUse
: 0 bytesKwWhere
: 0 bytesKwWhile
: 0 bytesKwYield
: 0 bytesSymAttSyntax
: 0 bytesSymClobberAbi
: 0 bytesSymInlateout
: 0 bytesSymInout
: 0 bytesSymIs
: 0 bytesSymLabel
: 0 bytesSymLateout
: 0 bytesSymMayUnwind
: 0 bytesSymNomem
: 0 bytesSymNoreturn
: 0 bytesSymNostack
: 0 bytesSymOptions
: 0 bytesSymOut
: 0 bytesSymPreservesFlags
: 0 bytesSymPure
: 0 bytesSymReadonly
: 0 bytesSymSym
: 0 bytes