@@ -2950,6 +2950,7 @@ impl Item {
2950
2950
| ItemKind :: GlobalAsm ( _)
2951
2951
| ItemKind :: MacCall ( _)
2952
2952
| ItemKind :: Delegation ( _)
2953
+ | ItemKind :: DelegationMac ( _)
2953
2954
| ItemKind :: MacroDef ( _) => None ,
2954
2955
ItemKind :: Static ( _) => None ,
2955
2956
ItemKind :: Const ( i) => Some ( & i. generics ) ,
@@ -3116,6 +3117,14 @@ pub struct Delegation {
3116
3117
pub body : Option < P < Block > > ,
3117
3118
}
3118
3119
3120
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3121
+ pub struct DelegationMac {
3122
+ pub qself : Option < P < QSelf > > ,
3123
+ pub prefix : Path ,
3124
+ pub suffixes : ThinVec < Ident > ,
3125
+ pub body : Option < P < Block > > ,
3126
+ }
3127
+
3119
3128
#[ derive( Clone , Encodable , Decodable , Debug ) ]
3120
3129
pub struct StaticItem {
3121
3130
pub ty : P < Ty > ,
@@ -3202,10 +3211,13 @@ pub enum ItemKind {
3202
3211
/// A macro definition.
3203
3212
MacroDef ( MacroDef ) ,
3204
3213
3205
- /// A delegation item (`reuse`).
3214
+ /// A single delegation item (`reuse`).
3206
3215
///
3207
3216
/// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
3208
3217
Delegation ( Box < Delegation > ) ,
3218
+ /// A list delegation item (`reuse prefix::{a, b, c}`).
3219
+ /// Treated similarly to a macro call and expanded early.
3220
+ DelegationMac ( Box < DelegationMac > ) ,
3209
3221
}
3210
3222
3211
3223
impl ItemKind {
@@ -3214,7 +3226,7 @@ impl ItemKind {
3214
3226
match self {
3215
3227
Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
3216
3228
| Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
3217
- | Delegation ( ..) => "a" ,
3229
+ | Delegation ( ..) | DelegationMac ( .. ) => "a" ,
3218
3230
ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
3219
3231
}
3220
3232
}
@@ -3239,6 +3251,7 @@ impl ItemKind {
3239
3251
ItemKind :: MacroDef ( ..) => "macro definition" ,
3240
3252
ItemKind :: Impl { .. } => "implementation" ,
3241
3253
ItemKind :: Delegation ( ..) => "delegated function" ,
3254
+ ItemKind :: DelegationMac ( ..) => "delegation" ,
3242
3255
}
3243
3256
}
3244
3257
@@ -3282,6 +3295,8 @@ pub enum AssocItemKind {
3282
3295
MacCall ( P < MacCall > ) ,
3283
3296
/// An associated delegation item.
3284
3297
Delegation ( Box < Delegation > ) ,
3298
+ /// An associated delegation item list.
3299
+ DelegationMac ( Box < DelegationMac > ) ,
3285
3300
}
3286
3301
3287
3302
impl AssocItemKind {
@@ -3290,7 +3305,9 @@ impl AssocItemKind {
3290
3305
Self :: Const ( box ConstItem { defaultness, .. } )
3291
3306
| Self :: Fn ( box Fn { defaultness, .. } )
3292
3307
| Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3293
- Self :: MacCall ( ..) | Self :: Delegation ( ..) => Defaultness :: Final ,
3308
+ Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
3309
+ Defaultness :: Final
3310
+ }
3294
3311
}
3295
3312
}
3296
3313
}
@@ -3303,6 +3320,7 @@ impl From<AssocItemKind> for ItemKind {
3303
3320
AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
3304
3321
AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
3305
3322
AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
3323
+ AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
3306
3324
}
3307
3325
}
3308
3326
}
@@ -3317,6 +3335,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
3317
3335
ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
3318
3336
ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
3319
3337
ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
3338
+ ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
3320
3339
_ => return Err ( item_kind) ,
3321
3340
} )
3322
3341
}
0 commit comments