Token in rustc_ast::token - Rust (original) (raw)
pub struct Token {
pub kind: TokenKind,
pub span: Span,
}
Some token that will be thrown away later.
Recovers a Token
from an Ident
. This creates a raw identifier if necessary.
Returns true
if the token can appear at the start of an expression.
NB: Take care when modifying this function, since it will change the stable set of tokens that are allowed to match an expr nonterminal.
Returns true
if the token can appear at the start of a pattern.
Shamelessly borrowed from can_begin_expr
, only used for diagnostics right now.
Returns true
if the token can appear at the start of a type.
Returns true
if the token can appear at the start of a const param.
Returns true
if the token can appear at the start of an item.
Returns true
if the token is any literal.
Returns true
if the token is any literal, a minus (which can prefix a literal, for example a ‘-42’, or one of the boolean idents).
In other words, would this token be a valid start of parse_literal_maybe_minus
?
Keep this in sync with Lit::from_token
and Parser::eat_token_lit
(excluding unary negation).
A convenience function for matching on identifiers during parsing. Turns interpolated identifier ($i: ident
) or lifetime ($l: lifetime
) token into the regular identifier or lifetime token it refers to, otherwise returns the original token.
Returns an identifier if this token is an identifier.
Returns a lifetime identifier if this token is a lifetime.
Returns true
if the token is an identifier.
Returns true
if the token is a lifetime.
Returns true
if the token is an identifier whose name is the given string slice.
Is this a pre-parsed expression dropped into the token stream (which happens while parsing the result of macro expansion)?
Are we at a block from a metavar ($b:block
)?
Returns true
if the token is either the mut
or const
keyword.
Returns true
if the token is a given keyword, kw
.
Returns true
if the token is a given keyword, kw
or if case
is Insensitive
and this token is an identifier equal to kw
ignoring the case.
Returns true for reserved identifiers used internally for elided lifetimes, unnamed method parameters, crate root module, error recovery etc.
Returns true
if the token is a keyword used in the language.
Returns true
if the token is a keyword reserved for possible future use.
Returns true
if the token is either a special identifier or a keyword.
Returns true
if the token is the identifier true
or false
.
Returns true
if the token is the integer literal.
Returns true
if the token is a non-raw identifier for which pred
holds.
Is this an invisible open delimiter at the start of a token sequence from an expanded metavar?
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: 24 bytes