Struct rustc_span::symbol::Ident
source · pub struct Ident {
pub name: Symbol,
pub span: Span,
}
Fields§
§name: Symbol
§span: Span
Implementations§
source§impl Ident
impl Ident
sourcepub const fn new(name: Symbol, span: Span) -> Ident
pub const fn new(name: Symbol, span: Span) -> Ident
Constructs a new identifier from a symbol and a span.
sourcepub const fn with_dummy_span(name: Symbol) -> Ident
pub const fn with_dummy_span(name: Symbol) -> Ident
Constructs a new identifier with a dummy span.
pub fn empty() -> Ident
sourcepub fn from_str_and_span(string: &str, span: Span) -> Ident
pub fn from_str_and_span(string: &str, span: Span) -> Ident
Maps a string and a span to an identifier.
sourcepub fn with_span_pos(self, span: Span) -> Ident
pub fn with_span_pos(self, span: Span) -> Ident
Replaces lo
and hi
with those from span
, but keep hygiene context.
pub fn without_first_quote(self) -> Ident
sourcepub fn normalize_to_macros_2_0(self) -> Ident
pub fn normalize_to_macros_2_0(self) -> Ident
“Normalize” ident for use in comparisons using “item hygiene”.
Identifiers with same string value become same if they came from the same macro 2.0 macro
(e.g., macro
item, but not macro_rules
item) and stay different if they came from
different macro 2.0 macros.
Technically, this operation strips all non-opaque marks from ident’s syntactic context.
sourcepub fn normalize_to_macro_rules(self) -> Ident
pub fn normalize_to_macro_rules(self) -> Ident
“Normalize” ident for use in comparisons using “local variable hygiene”.
Identifiers with same string value become same if they came from the same non-transparent
macro (e.g., macro
or macro_rules!
items) and stay different if they came from different
non-transparent macros.
Technically, this operation strips all transparent marks from ident’s syntactic context.
source§impl Ident
impl Ident
sourcepub fn is_special(self) -> bool
pub fn is_special(self) -> bool
Returns true
for reserved identifiers used internally for elided lifetimes,
unnamed method parameters, crate root module, error recovery etc.
sourcepub fn is_used_keyword(self) -> bool
pub fn is_used_keyword(self) -> bool
Returns true
if the token is a keyword used in the language.
sourcepub fn is_unused_keyword(self) -> bool
pub fn is_unused_keyword(self) -> bool
Returns true
if the token is a keyword reserved for possible future use.
sourcepub fn is_reserved(self) -> bool
pub fn is_reserved(self) -> bool
Returns true
if the token is either a special identifier or a keyword.
sourcepub fn is_path_segment_keyword(self) -> bool
pub fn is_path_segment_keyword(self) -> bool
A keyword or reserved identifier that can be used as a path segment.
sourcepub fn is_raw_guess(self) -> bool
pub fn is_raw_guess(self) -> bool
We see this identifier in a normal identifier position, like variable name or a type. How was it written originally? Did it use the raw form? Let’s try to guess.
Trait Implementations§
source§impl Display for Ident
impl Display for Ident
This implementation is supposed to be used in error messages, so it’s expected to be identical
to printing the original identifier token written in source code (token_to_string
),
except that AST identifiers don’t keep the rawness flag, so we have to guess it.
source§impl<__CTX> HashStable<__CTX> for Identwhere
__CTX: HashStableContext,
impl<__CTX> HashStable<__CTX> for Identwhere
__CTX: HashStableContext,
fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)
impl Copy for Ident
impl Eq for Ident
Auto Trait Implementations§
impl DynSend for Ident
impl DynSync for Ident
impl Freeze for Ident
impl RefUnwindSafe for Ident
impl Send for Ident
impl Sync for Ident
impl Unpin for Ident
impl UnwindSafe for Ident
Blanket Implementations§
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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<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,
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: 12 bytes