@@ -2961,6 +2961,7 @@ impl Item {
29612961 | ItemKind :: GlobalAsm ( _)
29622962 | ItemKind :: MacCall ( _)
29632963 | ItemKind :: Delegation ( _)
2964+ | ItemKind :: DelegationMac ( _)
29642965 | ItemKind :: MacroDef ( _) => None ,
29652966 ItemKind :: Static ( _) => None ,
29662967 ItemKind :: Const ( i) => Some ( & i. generics ) ,
@@ -3123,8 +3124,16 @@ pub struct Delegation {
31233124 /// Path resolution id.
31243125 pub id : NodeId ,
31253126 pub qself : Option < P < QSelf > > ,
3126- pub rename : Option < Ident > ,
31273127 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 > ) > ,
31283137 pub body : Option < P < Block > > ,
31293138}
31303139
@@ -3243,10 +3252,13 @@ pub enum ItemKind {
32433252 /// A macro definition.
32443253 MacroDef ( MacroDef ) ,
32453254
3246- /// A delegation item (`reuse`).
3255+ /// A single delegation item (`reuse`).
32473256 ///
32483257 /// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
32493258 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 > ) ,
32503262}
32513263
32523264impl ItemKind {
@@ -3256,7 +3268,7 @@ impl ItemKind {
32563268 match self {
32573269 Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
32583270 | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
3259- | Delegation ( ..) => "a" ,
3271+ | Delegation ( ..) | DelegationMac ( .. ) => "a" ,
32603272 ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
32613273 }
32623274 }
@@ -3281,6 +3293,7 @@ impl ItemKind {
32813293 ItemKind :: MacroDef ( ..) => "macro definition" ,
32823294 ItemKind :: Impl { .. } => "implementation" ,
32833295 ItemKind :: Delegation ( ..) => "delegated function" ,
3296+ ItemKind :: DelegationMac ( ..) => "delegation" ,
32843297 }
32853298 }
32863299
@@ -3324,6 +3337,8 @@ pub enum AssocItemKind {
33243337 MacCall ( P < MacCall > ) ,
33253338 /// An associated delegation item.
33263339 Delegation ( Box < Delegation > ) ,
3340+ /// An associated delegation item list.
3341+ DelegationMac ( Box < DelegationMac > ) ,
33273342}
33283343
33293344impl AssocItemKind {
@@ -3332,7 +3347,9 @@ impl AssocItemKind {
33323347 Self :: Const ( box ConstItem { defaultness, .. } )
33333348 | Self :: Fn ( box Fn { defaultness, .. } )
33343349 | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3335- Self :: MacCall ( ..) | Self :: Delegation ( ..) => Defaultness :: Final ,
3350+ Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
3351+ Defaultness :: Final
3352+ }
33363353 }
33373354 }
33383355}
@@ -3345,6 +3362,7 @@ impl From<AssocItemKind> for ItemKind {
33453362 AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
33463363 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
33473364 AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
3365+ AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
33483366 }
33493367 }
33503368}
@@ -3359,6 +3377,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
33593377 ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
33603378 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
33613379 ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
3380+ ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
33623381 _ => return Err ( item_kind) ,
33633382 } )
33643383 }
0 commit comments