[][src]Struct rustc_ast::ast::Lit

pub struct Lit {
    pub token: Lit,
    pub kind: LitKind,
    pub span: Span,
}

An AST literal.

Fields

token: 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

impl Lit[src]

pub fn from_lit_token(token: Lit, span: Span) -> Result<Lit, LitError>[src]

Converts literal token into an AST literal.

pub fn from_token(token: &Token) -> Result<Lit, LitError>[src]

Converts arbitrary token into an AST literal.

Keep this in sync with Token::can_begin_literal_or_bool excluding unary negation.

pub fn from_lit_kind(kind: LitKind, span: Span) -> Lit[src]

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

pub fn token_tree(&self) -> TokenTree[src]

Losslessly convert an AST literal into a token stream.

Trait Implementations

impl Clone for Lit[src]

impl Debug for Lit[src]

impl Decodable for Lit[src]

impl Encodable for Lit[src]

impl<__CTX> HashStable<__CTX> for Lit where
    __CTX: HashStableContext
[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Decodable for T where
    T: UseSpecializedDecodable
[src]

impl<T> Encodable for T where
    T: UseSpecializedEncodable + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.