@@ -2978,6 +2978,14 @@ pub struct Fn {
29782978 pub body : Option < P < Block > > ,
29792979}
29802980
2981+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
2982+ pub struct Delegation {
2983+ pub id : NodeId ,
2984+ pub path : ( Option < P < QSelf > > , Path ) ,
2985+ pub target_expr : Option < P < Expr > > ,
2986+ pub span : Span ,
2987+ }
2988+
29812989#[ derive( Clone , Encodable , Decodable , Debug ) ]
29822990pub struct StaticItem {
29832991 pub ty : P < Ty > ,
@@ -3063,14 +3071,20 @@ pub enum ItemKind {
30633071
30643072 /// A macro definition.
30653073 MacroDef ( MacroDef ) ,
3074+
3075+ /// A delegation item (`reuse`).
3076+ ///
3077+ /// E.g. reuse <Type as Trait>::name { target_expr_template }
3078+ Delegation ( Box < Delegation > ) ,
30663079}
30673080
30683081impl ItemKind {
30693082 pub fn article ( & self ) -> & ' static str {
30703083 use ItemKind :: * ;
30713084 match self {
30723085 Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
3073- | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..) => "a" ,
3086+ | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
3087+ | Delegation ( ..) => "a" ,
30743088 ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
30753089 }
30763090 }
@@ -3094,6 +3108,7 @@ impl ItemKind {
30943108 ItemKind :: MacCall ( ..) => "item macro invocation" ,
30953109 ItemKind :: MacroDef ( ..) => "macro definition" ,
30963110 ItemKind :: Impl { .. } => "implementation" ,
3111+ ItemKind :: Delegation ( ..) => "delegation" ,
30973112 }
30983113 }
30993114
@@ -3135,6 +3150,8 @@ pub enum AssocItemKind {
31353150 Type ( Box < TyAlias > ) ,
31363151 /// A macro expanding to associated items.
31373152 MacCall ( P < MacCall > ) ,
3153+ /// An associated delegation item.
3154+ Delegation ( Box < Delegation > ) ,
31383155}
31393156
31403157impl AssocItemKind {
@@ -3143,7 +3160,7 @@ impl AssocItemKind {
31433160 Self :: Const ( box ConstItem { defaultness, .. } )
31443161 | Self :: Fn ( box Fn { defaultness, .. } )
31453162 | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3146- Self :: MacCall ( ..) => Defaultness :: Final ,
3163+ Self :: MacCall ( ..) | Self :: Delegation ( .. ) => Defaultness :: Final ,
31473164 }
31483165 }
31493166}
@@ -3155,6 +3172,7 @@ impl From<AssocItemKind> for ItemKind {
31553172 AssocItemKind :: Fn ( fn_kind) => ItemKind :: Fn ( fn_kind) ,
31563173 AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
31573174 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
3175+ AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
31583176 }
31593177 }
31603178}
@@ -3168,6 +3186,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
31683186 ItemKind :: Fn ( fn_kind) => AssocItemKind :: Fn ( fn_kind) ,
31693187 ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
31703188 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
3189+ ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
31713190 _ => return Err ( item_kind) ,
31723191 } )
31733192 }
0 commit comments