pub enum NameClass<'db> {
Definition(Definition),
ConstReference(Definition),
PatFieldShorthand {
local_def: Local,
field_ref: Field,
adt_subst: GenericSubstitution<'db>,
},
}
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<'db> NameClass<'db>
impl<'db> NameClass<'db>
Sourcepub fn defined(self) -> Option<Definition>
pub fn defined(self) -> Option<Definition>
Definition
defined by this name.
pub fn classify( sema: &Semantics<'db, RootDatabase>, name: &Name, ) -> Option<NameClass<'db>>
pub fn classify_lifetime( sema: &Semantics<'db, RootDatabase>, lifetime: &Lifetime, ) -> Option<NameClass<'db>>
Trait Implementations§
Auto Trait Implementations§
impl<'db> Freeze for NameClass<'db>
impl<'db> !RefUnwindSafe for NameClass<'db>
impl<'db> Send for NameClass<'db>
impl<'db> Sync for NameClass<'db>
impl<'db> Unpin for NameClass<'db>
impl<'db> !UnwindSafe for NameClass<'db>
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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> 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