@@ -3640,6 +3640,8 @@ impl Item {
36403640 | ItemKind :: DelegationMac ( _)
36413641 | ItemKind :: MacroDef ( ..) => None ,
36423642 ItemKind :: Static ( _) => None ,
3643+ ItemKind :: AutoImpl ( ai) => Some ( & ai. generics ) ,
3644+ ItemKind :: ExternImpl ( ei) => Some ( & ei. generics ) ,
36433645 ItemKind :: Const ( i) => Some ( & i. generics ) ,
36443646 ItemKind :: Fn ( i) => Some ( & i. generics ) ,
36453647 ItemKind :: TyAlias ( i) => Some ( & i. generics ) ,
@@ -3783,6 +3785,20 @@ pub struct Impl {
37833785 pub items : ThinVec < Box < AssocItem > > ,
37843786}
37853787
3788+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3789+ pub struct AutoImpl {
3790+ pub generics : Generics ,
3791+ pub constness : Const ,
3792+ pub of_trait : Box < TraitImplHeader > ,
3793+ pub items : ThinVec < Box < AssocItem > > ,
3794+ }
3795+
3796+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3797+ pub struct ExternImpl {
3798+ pub generics : Generics ,
3799+ pub of_trait : Box < TraitImplHeader > ,
3800+ }
3801+
37863802#[ derive( Clone , Encodable , Decodable , Debug ) ]
37873803pub struct TraitImplHeader {
37883804 pub defaultness : Defaultness ,
@@ -3996,6 +4012,10 @@ pub enum ItemKind {
39964012 ///
39974013 /// E.g., `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`.
39984014 Impl ( Impl ) ,
4015+ /// An `auto impl` implementation, such as a supertrait `auto impl`.
4016+ AutoImpl ( Box < AutoImpl > ) ,
4017+ /// An `extern impl` directive
4018+ ExternImpl ( Box < ExternImpl > ) ,
39994019 /// A macro invocation.
40004020 ///
40014021 /// E.g., `foo!(..)`.
@@ -4034,6 +4054,8 @@ impl ItemKind {
40344054 | ItemKind :: ForeignMod ( _)
40354055 | ItemKind :: GlobalAsm ( _)
40364056 | ItemKind :: Impl ( _)
4057+ | ItemKind :: AutoImpl ( _)
4058+ | ItemKind :: ExternImpl ( _)
40374059 | ItemKind :: MacCall ( _)
40384060 | ItemKind :: DelegationMac ( _) => None ,
40394061 }
@@ -4046,7 +4068,13 @@ impl ItemKind {
40464068 Use ( ..) | Static ( ..) | Const ( ..) | ConstBlock ( ..) | Fn ( ..) | Mod ( ..)
40474069 | GlobalAsm ( ..) | TyAlias ( ..) | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..)
40484070 | MacroDef ( ..) | Delegation ( ..) | DelegationMac ( ..) => "a" ,
4049- ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
4071+ ExternCrate ( ..)
4072+ | ForeignMod ( ..)
4073+ | MacCall ( ..)
4074+ | Enum ( ..)
4075+ | Impl { .. }
4076+ | AutoImpl ( ..)
4077+ | ExternImpl ( ..) => "an" ,
40504078 }
40514079 }
40524080
@@ -4070,6 +4098,8 @@ impl ItemKind {
40704098 ItemKind :: MacCall ( ..) => "item macro invocation" ,
40714099 ItemKind :: MacroDef ( ..) => "macro definition" ,
40724100 ItemKind :: Impl { .. } => "implementation" ,
4101+ ItemKind :: AutoImpl { .. } => "`auto` implementation" ,
4102+ ItemKind :: ExternImpl { .. } => "`extern` implementation" ,
40734103 ItemKind :: Delegation ( ..) => "delegated function" ,
40744104 ItemKind :: DelegationMac ( ..) => "delegation" ,
40754105 }
@@ -4085,6 +4115,8 @@ impl ItemKind {
40854115 | Self :: Union ( _, generics, _)
40864116 | Self :: Trait ( box Trait { generics, .. } )
40874117 | Self :: TraitAlias ( box TraitAlias { generics, .. } )
4118+ | Self :: AutoImpl ( box AutoImpl { generics, .. } )
4119+ | Self :: ExternImpl ( box ExternImpl { generics, .. } )
40884120 | Self :: Impl ( Impl { generics, .. } ) => Some ( generics) ,
40894121
40904122 Self :: ExternCrate ( ..)
@@ -4128,6 +4160,10 @@ pub enum AssocItemKind {
41284160 Delegation ( Box < Delegation > ) ,
41294161 /// An associated list or glob delegation item.
41304162 DelegationMac ( Box < DelegationMac > ) ,
4163+ /// An `auto impl` item
4164+ AutoImpl ( Box < AutoImpl > ) ,
4165+ /// An `extern impl` item
4166+ ExternImpl ( Box < ExternImpl > ) ,
41314167}
41324168
41334169impl AssocItemKind {
@@ -4138,15 +4174,26 @@ impl AssocItemKind {
41384174 | AssocItemKind :: Type ( box TyAlias { ident, .. } )
41394175 | AssocItemKind :: Delegation ( box Delegation { ident, .. } ) => Some ( ident) ,
41404176
4141- AssocItemKind :: MacCall ( _) | AssocItemKind :: DelegationMac ( _) => None ,
4177+ AssocItemKind :: MacCall ( _)
4178+ | AssocItemKind :: DelegationMac ( _)
4179+ | AssocItemKind :: AutoImpl ( _)
4180+ | AssocItemKind :: ExternImpl ( _) => None ,
41424181 }
41434182 }
41444183
41454184 pub fn defaultness ( & self ) -> Defaultness {
41464185 match * self {
41474186 Self :: Const ( box ConstItem { defaultness, .. } )
41484187 | Self :: Fn ( box Fn { defaultness, .. } )
4149- | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
4188+ | Self :: Type ( box TyAlias { defaultness, .. } )
4189+ | Self :: AutoImpl ( box AutoImpl {
4190+ of_trait : box TraitImplHeader { defaultness, .. } ,
4191+ ..
4192+ } )
4193+ | Self :: ExternImpl ( box ExternImpl {
4194+ of_trait : box TraitImplHeader { defaultness, .. } ,
4195+ ..
4196+ } ) => defaultness,
41504197 Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
41514198 Defaultness :: Implicit
41524199 }
@@ -4163,6 +4210,8 @@ impl From<AssocItemKind> for ItemKind {
41634210 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
41644211 AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
41654212 AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
4213+ AssocItemKind :: AutoImpl ( ai) => ItemKind :: AutoImpl ( ai) ,
4214+ AssocItemKind :: ExternImpl ( ei) => ItemKind :: ExternImpl ( ei) ,
41664215 }
41674216 }
41684217}
@@ -4178,6 +4227,8 @@ impl TryFrom<ItemKind> for AssocItemKind {
41784227 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
41794228 ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
41804229 ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
4230+ ItemKind :: AutoImpl ( ai) => AssocItemKind :: AutoImpl ( ai) ,
4231+ ItemKind :: ExternImpl ( ei) => AssocItemKind :: ExternImpl ( ei) ,
41814232 _ => return Err ( item_kind) ,
41824233 } )
41834234 }
0 commit comments