@@ -2950,6 +2950,7 @@ impl Item {
29502950 | ItemKind :: GlobalAsm ( _)
29512951 | ItemKind :: MacCall ( _)
29522952 | ItemKind :: Delegation ( _)
2953+ | ItemKind :: DelegationMac ( _)
29532954 | ItemKind :: MacroDef ( _) => None ,
29542955 ItemKind :: Static ( _) => None ,
29552956 ItemKind :: Const ( i) => Some ( & i. generics ) ,
@@ -3112,8 +3113,16 @@ pub struct Delegation {
31123113 /// Path resolution id.
31133114 pub id : NodeId ,
31143115 pub qself : Option < P < QSelf > > ,
3115- pub rename : Option < Ident > ,
31163116 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 > ) > ,
31173126 pub body : Option < P < Block > > ,
31183127}
31193128
@@ -3203,10 +3212,13 @@ pub enum ItemKind {
32033212 /// A macro definition.
32043213 MacroDef ( MacroDef ) ,
32053214
3206- /// A delegation item (`reuse`).
3215+ /// A single delegation item (`reuse`).
32073216 ///
32083217 /// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
32093218 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 > ) ,
32103222}
32113223
32123224impl ItemKind {
@@ -3215,7 +3227,7 @@ impl ItemKind {
32153227 match self {
32163228 Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
32173229 | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
3218- | Delegation ( ..) => "a" ,
3230+ | Delegation ( ..) | DelegationMac ( .. ) => "a" ,
32193231 ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
32203232 }
32213233 }
@@ -3240,6 +3252,7 @@ impl ItemKind {
32403252 ItemKind :: MacroDef ( ..) => "macro definition" ,
32413253 ItemKind :: Impl { .. } => "implementation" ,
32423254 ItemKind :: Delegation ( ..) => "delegated function" ,
3255+ ItemKind :: DelegationMac ( ..) => "delegation" ,
32433256 }
32443257 }
32453258
@@ -3283,6 +3296,8 @@ pub enum AssocItemKind {
32833296 MacCall ( P < MacCall > ) ,
32843297 /// An associated delegation item.
32853298 Delegation ( Box < Delegation > ) ,
3299+ /// An associated delegation item list.
3300+ DelegationMac ( Box < DelegationMac > ) ,
32863301}
32873302
32883303impl AssocItemKind {
@@ -3291,7 +3306,9 @@ impl AssocItemKind {
32913306 Self :: Const ( box ConstItem { defaultness, .. } )
32923307 | Self :: Fn ( box Fn { defaultness, .. } )
32933308 | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3294- Self :: MacCall ( ..) | Self :: Delegation ( ..) => Defaultness :: Final ,
3309+ Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
3310+ Defaultness :: Final
3311+ }
32953312 }
32963313 }
32973314}
@@ -3304,6 +3321,7 @@ impl From<AssocItemKind> for ItemKind {
33043321 AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
33053322 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
33063323 AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
3324+ AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
33073325 }
33083326 }
33093327}
@@ -3318,6 +3336,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
33183336 ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
33193337 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
33203338 ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
3339+ ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
33213340 _ => return Err ( item_kind) ,
33223341 } )
33233342 }
0 commit comments