@@ -253,7 +253,9 @@ impl DefKind {
253253 }
254254 }
255255
256- pub fn def_path_data ( self , name : Symbol ) -> DefPathData {
256+ // Some `DefKind`s require a name, some don't. Panics if one is needed but
257+ // not provided. (`AssocTy` is an exception, see below.)
258+ pub fn def_path_data ( self , name : Option < Symbol > ) -> DefPathData {
257259 match self {
258260 DefKind :: Mod
259261 | DefKind :: Struct
@@ -264,9 +266,13 @@ impl DefKind {
264266 | DefKind :: TyAlias
265267 | DefKind :: ForeignTy
266268 | DefKind :: TraitAlias
267- | DefKind :: AssocTy
268269 | DefKind :: TyParam
269- | DefKind :: ExternCrate => DefPathData :: TypeNs ( name) ,
270+ | DefKind :: ExternCrate => DefPathData :: TypeNs ( Some ( name. unwrap ( ) ) ) ,
271+
272+ // An associated type names will be missing for an RPITIT. It will
273+ // later be given a name with `synthetic` in it, if necessary.
274+ DefKind :: AssocTy => DefPathData :: TypeNs ( name) ,
275+
270276 // It's not exactly an anon const, but wrt DefPathData, there
271277 // is no difference.
272278 DefKind :: Static { nested : true , .. } => DefPathData :: AnonConst ,
@@ -276,9 +282,9 @@ impl DefKind {
276282 | DefKind :: Static { .. }
277283 | DefKind :: AssocFn
278284 | DefKind :: AssocConst
279- | DefKind :: Field => DefPathData :: ValueNs ( name) ,
280- DefKind :: Macro ( ..) => DefPathData :: MacroNs ( name) ,
281- DefKind :: LifetimeParam => DefPathData :: LifetimeNs ( name) ,
285+ | DefKind :: Field => DefPathData :: ValueNs ( name. unwrap ( ) ) ,
286+ DefKind :: Macro ( ..) => DefPathData :: MacroNs ( name. unwrap ( ) ) ,
287+ DefKind :: LifetimeParam => DefPathData :: LifetimeNs ( name. unwrap ( ) ) ,
282288 DefKind :: Ctor ( ..) => DefPathData :: Ctor ,
283289 DefKind :: Use => DefPathData :: Use ,
284290 DefKind :: ForeignMod => DefPathData :: ForeignMod ,
0 commit comments