[−][src]Struct rustc_ap_rustc_ast::ast::Lit
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
Methods
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]
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<'a, T> Captures<'a> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Decodable for T where
T: UseSpecializedDecodable,
[src]
T: UseSpecializedDecodable,
impl<T> Encodable for T where
T: UseSpecializedEncodable + ?Sized,
[src]
T: UseSpecializedEncodable + ?Sized,
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<E> SpecializationError for E
[src]
default fn not_found<S, T>(
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
[src]
trait_name: &'static str,
method_name: &'static str
) -> E where
T: ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,