pub enum NameClass {
Definition(Definition),
ConstReference(Definition),
PatFieldShorthand {
local_def: Local,
field_ref: Field,
},
}
Expand description
On a first blush, a single ast::Name
defines a single definition at some
scope. That is, that, by just looking at the syntactical category, we can
unambiguously define the semantic category.
Sadly, that’s not 100% true, there are special cases. To make sure that
callers handle all the special cases correctly via exhaustive matching, we
add a NameClass
enum which lists all of them!
A model special case is None
constant in pattern.
Variants§
Definition(Definition)
ConstReference(Definition)
None
in if let None = Some(82) {}
.
Syntactically, it is a name, but semantically it is a reference.
PatFieldShorthand
field
in if let Foo { field } = foo
. Here, ast::Name
both introduces
a definition into a local scope, and refers to an existing definition.
Implementations§
source§impl NameClass
impl NameClass
sourcepub fn defined(self) -> Option<Definition>
pub fn defined(self) -> Option<Definition>
Definition
defined by this name.
pub fn classify( sema: &Semantics<'_, RootDatabase>, name: &Name, ) -> Option<NameClass>
pub fn classify_lifetime( sema: &Semantics<'_, RootDatabase>, lifetime: &Lifetime, ) -> Option<NameClass>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NameClass
impl RefUnwindSafe for NameClass
impl Send for NameClass
impl Sync for NameClass
impl Unpin for NameClass
impl UnwindSafe for NameClass
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
Mutably borrows from an owned value. Read more
§impl<T> Cast for T
impl<T> Cast for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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> ⓘ
Converts
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> ⓘ
Converts
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 more