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