@@ -3635,6 +3635,8 @@ impl Item {
36353635 | ItemKind :: DelegationMac ( _)
36363636 | ItemKind :: MacroDef ( ..) => None ,
36373637 ItemKind :: Static ( _) => None ,
3638+ ItemKind :: AutoImpl ( ai) => Some ( & ai. generics ) ,
3639+ ItemKind :: ExternImpl ( ei) => Some ( & ei. generics ) ,
36383640 ItemKind :: Const ( i) => Some ( & i. generics ) ,
36393641 ItemKind :: Fn ( i) => Some ( & i. generics ) ,
36403642 ItemKind :: TyAlias ( i) => Some ( & i. generics ) ,
@@ -3778,6 +3780,20 @@ pub struct Impl {
37783780 pub items : ThinVec < Box < AssocItem > > ,
37793781}
37803782
3783+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3784+ pub struct AutoImpl {
3785+ pub generics : Generics ,
3786+ pub constness : Const ,
3787+ pub of_trait : Box < TraitImplHeader > ,
3788+ pub items : ThinVec < Box < AssocItem > > ,
3789+ }
3790+
3791+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3792+ pub struct ExternImpl {
3793+ pub generics : Generics ,
3794+ pub of_trait : Box < TraitImplHeader > ,
3795+ }
3796+
37813797#[ derive( Clone , Encodable , Decodable , Debug ) ]
37823798pub struct TraitImplHeader {
37833799 pub defaultness : Defaultness ,
@@ -3958,6 +3974,10 @@ pub enum ItemKind {
39583974 ///
39593975 /// E.g., `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`.
39603976 Impl ( Impl ) ,
3977+ /// An `auto impl` implementation, such as a supertrait `auto impl`.
3978+ AutoImpl ( Box < AutoImpl > ) ,
3979+ /// An `extern impl` directive
3980+ ExternImpl ( Box < ExternImpl > ) ,
39613981 /// A macro invocation.
39623982 ///
39633983 /// E.g., `foo!(..)`.
@@ -3994,6 +4014,8 @@ impl ItemKind {
39944014 | ItemKind :: ForeignMod ( _)
39954015 | ItemKind :: GlobalAsm ( _)
39964016 | ItemKind :: Impl ( _)
4017+ | ItemKind :: AutoImpl ( _)
4018+ | ItemKind :: ExternImpl ( _)
39974019 | ItemKind :: MacCall ( _)
39984020 | ItemKind :: DelegationMac ( _) => None ,
39994021 }
@@ -4006,7 +4028,13 @@ impl ItemKind {
40064028 Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
40074029 | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
40084030 | Delegation ( ..) | DelegationMac ( ..) => "a" ,
4009- ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
4031+ ExternCrate ( ..)
4032+ | ForeignMod ( ..)
4033+ | MacCall ( ..)
4034+ | Enum ( ..)
4035+ | Impl { .. }
4036+ | AutoImpl ( ..)
4037+ | ExternImpl ( ..) => "an" ,
40104038 }
40114039 }
40124040
@@ -4029,6 +4057,8 @@ impl ItemKind {
40294057 ItemKind :: MacCall ( ..) => "item macro invocation" ,
40304058 ItemKind :: MacroDef ( ..) => "macro definition" ,
40314059 ItemKind :: Impl { .. } => "implementation" ,
4060+ ItemKind :: AutoImpl { .. } => "`auto` implementation" ,
4061+ ItemKind :: ExternImpl { .. } => "`extern` implementation" ,
40324062 ItemKind :: Delegation ( ..) => "delegated function" ,
40334063 ItemKind :: DelegationMac ( ..) => "delegation" ,
40344064 }
@@ -4076,6 +4106,8 @@ pub enum AssocItemKind {
40764106 Delegation ( Box < Delegation > ) ,
40774107 /// An associated list or glob delegation item.
40784108 DelegationMac ( Box < DelegationMac > ) ,
4109+ /// An `auto impl` item
4110+ AutoImpl ( Box < AutoImpl > ) ,
40794111}
40804112
40814113impl AssocItemKind {
@@ -4086,15 +4118,21 @@ impl AssocItemKind {
40864118 | AssocItemKind :: Type ( box TyAlias { ident, .. } )
40874119 | AssocItemKind :: Delegation ( box Delegation { ident, .. } ) => Some ( ident) ,
40884120
4089- AssocItemKind :: MacCall ( _) | AssocItemKind :: DelegationMac ( _) => None ,
4121+ AssocItemKind :: MacCall ( _)
4122+ | AssocItemKind :: DelegationMac ( _)
4123+ | AssocItemKind :: AutoImpl ( _) => None ,
40904124 }
40914125 }
40924126
40934127 pub fn defaultness ( & self ) -> Defaultness {
40944128 match * self {
40954129 Self :: Const ( box ConstItem { defaultness, .. } )
40964130 | Self :: Fn ( box Fn { defaultness, .. } )
4097- | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
4131+ | Self :: Type ( box TyAlias { defaultness, .. } )
4132+ | Self :: AutoImpl ( box AutoImpl {
4133+ of_trait : box TraitImplHeader { defaultness, .. } ,
4134+ ..
4135+ } ) => defaultness,
40984136 Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
40994137 Defaultness :: Final
41004138 }
@@ -4111,6 +4149,7 @@ impl From<AssocItemKind> for ItemKind {
41114149 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
41124150 AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
41134151 AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
4152+ AssocItemKind :: AutoImpl ( ai) => ItemKind :: AutoImpl ( ai) ,
41144153 }
41154154 }
41164155}
@@ -4126,6 +4165,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
41264165 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
41274166 ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
41284167 ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
4168+ ItemKind :: AutoImpl ( ai) => AssocItemKind :: AutoImpl ( ai) ,
41294169 _ => return Err ( item_kind) ,
41304170 } )
41314171 }
0 commit comments