Expand description
An AST literal.
Fields
token_lit: Lit
The original literal token as written in source code.
kind: LitKind
The “semantic” representation of the literal lowered from the original tokens. Strings are unescaped, hexadecimal forms are eliminated, etc. FIXME: Remove this and only create the semantic representation during lowering to HIR.
span: Span
Implementations
sourceimpl Lit
impl Lit
sourcepub fn from_token_lit(token_lit: Lit, span: Span) -> Result<Lit, LitError>
pub fn from_token_lit(token_lit: Lit, span: Span) -> Result<Lit, LitError>
Converts literal token into an AST literal.
sourcepub fn from_token(token: &Token) -> Result<Lit, LitError>
pub fn from_token(token: &Token) -> Result<Lit, LitError>
Converts arbitrary token into an AST literal.
Keep this in sync with Token::can_begin_literal_or_bool
excluding unary negation.
sourcepub fn from_lit_kind(kind: LitKind, span: Span) -> Lit
pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit
Attempts to recover an AST literal from semantic literal. This function is used when the original token doesn’t exist (e.g. the literal is created by an AST-based macro) or unavailable (e.g. from HIR pretty-printing).
Trait Implementations
sourceimpl<__CTX> HashStable<__CTX> for Litwhere
__CTX: HashStableContext,
impl<__CTX> HashStable<__CTX> for Litwhere
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
Auto Trait Implementations
impl RefUnwindSafe for Lit
impl !Send for Lit
impl !Sync for Lit
impl Unpin for Lit
impl UnwindSafe for Lit
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut 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: 48 bytes