Introduce DefPathData::AnonAssocTy
.
PR #137977 changed `DefPathData::TypeNs` to contain `Option<Symbol>` to account for RPITIT assoc types being anonymous. This commit changes it back to `Symbol` and gives anonymous assoc types their own variant. It makes things a bit nicer overall.
This commit is contained in:
parent
fad2535e4b
commit
9eca59a940
8 changed files with 30 additions and 27 deletions
|
@ -267,11 +267,16 @@ impl DefKind {
|
|||
| DefKind::ForeignTy
|
||||
| DefKind::TraitAlias
|
||||
| DefKind::TyParam
|
||||
| DefKind::ExternCrate => DefPathData::TypeNs(Some(name.unwrap())),
|
||||
| DefKind::ExternCrate => DefPathData::TypeNs(name.unwrap()),
|
||||
|
||||
// An associated type names will be missing for an RPITIT. It will
|
||||
// later be given a name with `synthetic` in it, if necessary.
|
||||
DefKind::AssocTy => DefPathData::TypeNs(name),
|
||||
// An associated type name will be missing for an RPITIT.
|
||||
DefKind::AssocTy => {
|
||||
if let Some(name) = name {
|
||||
DefPathData::TypeNs(name)
|
||||
} else {
|
||||
DefPathData::AnonAssocTy
|
||||
}
|
||||
}
|
||||
|
||||
// It's not exactly an anon const, but wrt DefPathData, there
|
||||
// is no difference.
|
||||
|
|
|
@ -271,9 +271,8 @@ pub enum DefPathData {
|
|||
Use,
|
||||
/// A global asm item.
|
||||
GlobalAsm,
|
||||
/// Something in the type namespace. Will be empty for RPITIT associated
|
||||
/// types, which are given a synthetic name later, if necessary.
|
||||
TypeNs(Option<Symbol>),
|
||||
/// Something in the type namespace.
|
||||
TypeNs(Symbol),
|
||||
/// Something in the value namespace.
|
||||
ValueNs(Symbol),
|
||||
/// Something in the macro namespace.
|
||||
|
@ -291,6 +290,8 @@ pub enum DefPathData {
|
|||
/// An existential `impl Trait` type node.
|
||||
/// Argument position `impl Trait` have a `TypeNs` with their pretty-printed name.
|
||||
OpaqueTy,
|
||||
/// An anonymous associated type from an RPITIT.
|
||||
AnonAssocTy,
|
||||
/// A synthetic body for a coroutine's by-move body.
|
||||
SyntheticCoroutineBody,
|
||||
}
|
||||
|
@ -413,9 +414,7 @@ impl DefPathData {
|
|||
pub fn get_opt_name(&self) -> Option<Symbol> {
|
||||
use self::DefPathData::*;
|
||||
match *self {
|
||||
TypeNs(name) => name,
|
||||
|
||||
ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
|
||||
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => Some(name),
|
||||
|
||||
Impl
|
||||
| ForeignMod
|
||||
|
@ -426,6 +425,7 @@ impl DefPathData {
|
|||
| Ctor
|
||||
| AnonConst
|
||||
| OpaqueTy
|
||||
| AnonAssocTy
|
||||
| SyntheticCoroutineBody => None,
|
||||
}
|
||||
}
|
||||
|
@ -433,14 +433,9 @@ impl DefPathData {
|
|||
pub fn name(&self) -> DefPathDataName {
|
||||
use self::DefPathData::*;
|
||||
match *self {
|
||||
TypeNs(name) => {
|
||||
if let Some(name) = name {
|
||||
DefPathDataName::Named(name)
|
||||
} else {
|
||||
DefPathDataName::Anon { namespace: sym::synthetic }
|
||||
}
|
||||
TypeNs(name) | ValueNs(name) | MacroNs(name) | LifetimeNs(name) => {
|
||||
DefPathDataName::Named(name)
|
||||
}
|
||||
ValueNs(name) | MacroNs(name) | LifetimeNs(name) => DefPathDataName::Named(name),
|
||||
// Note that this does not show up in user print-outs.
|
||||
CrateRoot => DefPathDataName::Anon { namespace: kw::Crate },
|
||||
Impl => DefPathDataName::Anon { namespace: kw::Impl },
|
||||
|
@ -451,6 +446,7 @@ impl DefPathData {
|
|||
Ctor => DefPathDataName::Anon { namespace: sym::constructor },
|
||||
AnonConst => DefPathDataName::Anon { namespace: sym::constant },
|
||||
OpaqueTy => DefPathDataName::Anon { namespace: sym::opaque },
|
||||
AnonAssocTy => DefPathDataName::Anon { namespace: sym::synthetic },
|
||||
SyntheticCoroutineBody => DefPathDataName::Anon { namespace: sym::synthetic },
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue