@@ -2873,6 +2873,7 @@ impl Item {
28732873 | ItemKind :: ForeignMod ( _)
28742874 | ItemKind :: GlobalAsm ( _)
28752875 | ItemKind :: MacCall ( _)
2876+ | ItemKind :: Delegation ( _)
28762877 | ItemKind :: MacroDef ( _) => None ,
28772878 ItemKind :: Static ( _) => None ,
28782879 ItemKind :: Const ( i) => Some ( & i. generics ) ,
@@ -3019,6 +3020,15 @@ pub struct Fn {
30193020 pub body : Option < P < Block > > ,
30203021}
30213022
3023+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3024+ pub struct Delegation {
3025+ /// Path resolution id.
3026+ pub id : NodeId ,
3027+ pub qself : Option < P < QSelf > > ,
3028+ pub path : Path ,
3029+ pub body : Option < P < Block > > ,
3030+ }
3031+
30223032#[ derive( Clone , Encodable , Decodable , Debug ) ]
30233033pub struct StaticItem {
30243034 pub ty : P < Ty > ,
@@ -3104,14 +3114,20 @@ pub enum ItemKind {
31043114
31053115 /// A macro definition.
31063116 MacroDef ( MacroDef ) ,
3117+
3118+ /// A delegation item (`reuse`).
3119+ ///
3120+ /// E.g. `reuse <Type as Trait>::name { target_expr_template }`.
3121+ Delegation ( Box < Delegation > ) ,
31073122}
31083123
31093124impl ItemKind {
31103125 pub fn article ( & self ) -> & ' static str {
31113126 use ItemKind :: * ;
31123127 match self {
31133128 Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
3114- | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..) => "a" ,
3129+ | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
3130+ | Delegation ( ..) => "a" ,
31153131 ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
31163132 }
31173133 }
@@ -3135,6 +3151,7 @@ impl ItemKind {
31353151 ItemKind :: MacCall ( ..) => "item macro invocation" ,
31363152 ItemKind :: MacroDef ( ..) => "macro definition" ,
31373153 ItemKind :: Impl { .. } => "implementation" ,
3154+ ItemKind :: Delegation ( ..) => "delegated function" ,
31383155 }
31393156 }
31403157
@@ -3176,6 +3193,8 @@ pub enum AssocItemKind {
31763193 Type ( Box < TyAlias > ) ,
31773194 /// A macro expanding to associated items.
31783195 MacCall ( P < MacCall > ) ,
3196+ /// An associated delegation item.
3197+ Delegation ( Box < Delegation > ) ,
31793198}
31803199
31813200impl AssocItemKind {
@@ -3184,7 +3203,7 @@ impl AssocItemKind {
31843203 Self :: Const ( box ConstItem { defaultness, .. } )
31853204 | Self :: Fn ( box Fn { defaultness, .. } )
31863205 | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
3187- Self :: MacCall ( ..) => Defaultness :: Final ,
3206+ Self :: MacCall ( ..) | Self :: Delegation ( .. ) => Defaultness :: Final ,
31883207 }
31893208 }
31903209}
@@ -3196,6 +3215,7 @@ impl From<AssocItemKind> for ItemKind {
31963215 AssocItemKind :: Fn ( fn_kind) => ItemKind :: Fn ( fn_kind) ,
31973216 AssocItemKind :: Type ( ty_alias_kind) => ItemKind :: TyAlias ( ty_alias_kind) ,
31983217 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
3218+ AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
31993219 }
32003220 }
32013221}
@@ -3209,6 +3229,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
32093229 ItemKind :: Fn ( fn_kind) => AssocItemKind :: Fn ( fn_kind) ,
32103230 ItemKind :: TyAlias ( ty_kind) => AssocItemKind :: Type ( ty_kind) ,
32113231 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
3232+ ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
32123233 _ => return Err ( item_kind) ,
32133234 } )
32143235 }
0 commit comments