@@ -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 {
@@ -3256,7 +3268,7 @@ impl ItemKind {
3256
3268
match self {
3257
3269
Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
3258
3270
| Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
3259
- | Delegation ( ..) => "a" ,
3271
+ | Delegation ( ..) | DelegationMac ( .. ) => "a" ,
3260
3272
ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
3261
3273
}
3262
3274
}
@@ -3281,6 +3293,7 @@ impl ItemKind {
3281
3293
ItemKind :: MacroDef ( ..) => "macro definition" ,
3282
3294
ItemKind :: Impl { .. } => "implementation" ,
3283
3295
ItemKind :: Delegation ( ..) => "delegated function" ,
3296
+ ItemKind :: DelegationMac ( ..) => "delegation" ,
3284
3297
}
3285
3298
}
3286
3299
@@ -3324,6 +3337,8 @@ pub enum AssocItemKind {
3324
3337
MacCall ( P < MacCall > ) ,
3325
3338
/// An associated delegation item.
3326
3339
Delegation ( Box < Delegation > ) ,
3340
+ /// An associated delegation item list.
3341
+ DelegationMac ( Box < DelegationMac > ) ,
3327
3342
}
3328
3343
3329
3344
impl AssocItemKind {
@@ -3332,7 +3347,9 @@ impl AssocItemKind {
3332
3347
Self :: Const ( box ConstItem { defaultness, .. } )
3333
3348
| Self :: Fn ( box Fn { defaultness, .. } )
3334
3349
| Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3335
- Self :: MacCall ( ..) | Self :: Delegation ( ..) => Defaultness :: Final ,
3350
+ Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
3351
+ Defaultness :: Final
3352
+ }
3336
3353
}
3337
3354
}
3338
3355
}
@@ -3345,6 +3362,7 @@ impl From<AssocItemKind> for ItemKind {
3345
3362
AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
3346
3363
AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
3347
3364
AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
3365
+ AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
3348
3366
}
3349
3367
}
3350
3368
}
@@ -3359,6 +3377,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
3359
3377
ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
3360
3378
ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
3361
3379
ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
3380
+ ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
3362
3381
_ => return Err ( item_kind) ,
3363
3382
} )
3364
3383
}
0 commit comments