@@ -2961,6 +2961,7 @@ impl Item {
2961
2961
| ItemKind :: GlobalAsm ( _)
2962
2962
| ItemKind :: MacCall ( _)
2963
2963
| ItemKind :: Delegation ( _)
2964
+ | ItemKind :: DelegationMac ( _)
2964
2965
| ItemKind :: MacroDef ( _) => None ,
2965
2966
ItemKind :: Static ( _) => None ,
2966
2967
ItemKind :: Const ( i) => Some ( & i. generics ) ,
@@ -3123,8 +3124,16 @@ pub struct Delegation {
3123
3124
/// Path resolution id.
3124
3125
pub id : NodeId ,
3125
3126
pub qself : Option < P < QSelf > > ,
3126
- pub rename : Option < Ident > ,
3127
3127
pub path : Path ,
3128
+ pub rename : Option < Ident > ,
3129
+ pub body : Option < P < Block > > ,
3130
+ }
3131
+
3132
+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3133
+ pub struct DelegationMac {
3134
+ pub qself : Option < P < QSelf > > ,
3135
+ pub prefix : Path ,
3136
+ pub suffixes : ThinVec < ( Ident , Option < Ident > ) > ,
3128
3137
pub body : Option < P < Block > > ,
3129
3138
}
3130
3139
@@ -3243,10 +3252,13 @@ pub enum ItemKind {
3243
3252
/// A macro definition.
3244
3253
MacroDef ( MacroDef ) ,
3245
3254
3246
- /// A delegation item (`reuse`).
3255
+ /// A single delegation item (`reuse`).
3247
3256
///
3248
3257
/// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
3249
3258
Delegation ( Box < Delegation > ) ,
3259
+ /// A list delegation item (`reuse prefix::{a, b, c}`).
3260
+ /// Treated similarly to a macro call and expanded early.
3261
+ DelegationMac ( Box < DelegationMac > ) ,
3250
3262
}
3251
3263
3252
3264
impl ItemKind {
@@ -3255,7 +3267,7 @@ impl ItemKind {
3255
3267
match self {
3256
3268
Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
3257
3269
| Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
3258
- | Delegation ( ..) => "a" ,
3270
+ | Delegation ( ..) | DelegationMac ( .. ) => "a" ,
3259
3271
ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
3260
3272
}
3261
3273
}
@@ -3280,6 +3292,7 @@ impl ItemKind {
3280
3292
ItemKind :: MacroDef ( ..) => "macro definition" ,
3281
3293
ItemKind :: Impl { .. } => "implementation" ,
3282
3294
ItemKind :: Delegation ( ..) => "delegated function" ,
3295
+ ItemKind :: DelegationMac ( ..) => "delegation" ,
3283
3296
}
3284
3297
}
3285
3298
@@ -3323,6 +3336,8 @@ pub enum AssocItemKind {
3323
3336
MacCall ( P < MacCall > ) ,
3324
3337
/// An associated delegation item.
3325
3338
Delegation ( Box < Delegation > ) ,
3339
+ /// An associated delegation item list.
3340
+ DelegationMac ( Box < DelegationMac > ) ,
3326
3341
}
3327
3342
3328
3343
impl AssocItemKind {
@@ -3331,7 +3346,9 @@ impl AssocItemKind {
3331
3346
Self :: Const ( box ConstItem { defaultness, .. } )
3332
3347
| Self :: Fn ( box Fn { defaultness, .. } )
3333
3348
| Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3334
- Self :: MacCall ( ..) | Self :: Delegation ( ..) => Defaultness :: Final ,
3349
+ Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
3350
+ Defaultness :: Final
3351
+ }
3335
3352
}
3336
3353
}
3337
3354
}
@@ -3344,6 +3361,7 @@ impl From<AssocItemKind> for ItemKind {
3344
3361
AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
3345
3362
AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
3346
3363
AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
3364
+ AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
3347
3365
}
3348
3366
}
3349
3367
}
@@ -3358,6 +3376,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
3358
3376
ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
3359
3377
ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
3360
3378
ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
3379
+ ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
3361
3380
_ => return Err ( item_kind) ,
3362
3381
} )
3363
3382
}
0 commit comments