@@ -253,7 +253,9 @@ impl DefKind {
253
253
}
254
254
}
255
255
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 {
257
259
match self {
258
260
DefKind :: Mod
259
261
| DefKind :: Struct
@@ -264,9 +266,13 @@ impl DefKind {
264
266
| DefKind :: TyAlias
265
267
| DefKind :: ForeignTy
266
268
| DefKind :: TraitAlias
267
- | DefKind :: AssocTy
268
269
| 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
+
270
276
// It's not exactly an anon const, but wrt DefPathData, there
271
277
// is no difference.
272
278
DefKind :: Static { nested : true , .. } => DefPathData :: AnonConst ,
@@ -276,9 +282,9 @@ impl DefKind {
276
282
| DefKind :: Static { .. }
277
283
| DefKind :: AssocFn
278
284
| 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 ( ) ) ,
282
288
DefKind :: Ctor ( ..) => DefPathData :: Ctor ,
283
289
DefKind :: Use => DefPathData :: Use ,
284
290
DefKind :: ForeignMod => DefPathData :: ForeignMod ,
0 commit comments