@@ -3645,6 +3645,8 @@ impl Item {
36453645 | ItemKind :: DelegationMac ( _)
36463646 | ItemKind :: MacroDef ( ..) => None ,
36473647 ItemKind :: Static ( _) => None ,
3648+ ItemKind :: AutoImpl ( ai) => Some ( & ai. generics ) ,
3649+ ItemKind :: ExternImpl ( ei) => Some ( & ei. generics ) ,
36483650 ItemKind :: Const ( i) => Some ( & i. generics ) ,
36493651 ItemKind :: Fn ( i) => Some ( & i. generics ) ,
36503652 ItemKind :: TyAlias ( i) => Some ( & i. generics ) ,
@@ -3788,6 +3790,20 @@ pub struct Impl {
37883790 pub items : ThinVec < Box < AssocItem > > ,
37893791}
37903792
3793+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3794+ pub struct AutoImpl {
3795+ pub generics : Generics ,
3796+ pub constness : Const ,
3797+ pub of_trait : Box < TraitImplHeader > ,
3798+ pub items : ThinVec < Box < AssocItem > > ,
3799+ }
3800+
3801+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3802+ pub struct ExternImpl {
3803+ pub generics : Generics ,
3804+ pub of_trait : Box < TraitImplHeader > ,
3805+ }
3806+
37913807#[ derive( Clone , Encodable , Decodable , Debug ) ]
37923808pub struct TraitImplHeader {
37933809 pub defaultness : Defaultness ,
@@ -4001,6 +4017,10 @@ pub enum ItemKind {
40014017 ///
40024018 /// E.g., `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`.
40034019 Impl ( Impl ) ,
4020+ /// An `auto impl` implementation, such as a supertrait `auto impl`.
4021+ AutoImpl ( Box < AutoImpl > ) ,
4022+ /// An `extern impl` directive
4023+ ExternImpl ( Box < ExternImpl > ) ,
40044024 /// A macro invocation.
40054025 ///
40064026 /// E.g., `foo!(..)`.
@@ -4039,6 +4059,8 @@ impl ItemKind {
40394059 | ItemKind :: ForeignMod ( _)
40404060 | ItemKind :: GlobalAsm ( _)
40414061 | ItemKind :: Impl ( _)
4062+ | ItemKind :: AutoImpl ( _)
4063+ | ItemKind :: ExternImpl ( _)
40424064 | ItemKind :: MacCall ( _)
40434065 | ItemKind :: DelegationMac ( _) => None ,
40444066 }
@@ -4051,7 +4073,13 @@ impl ItemKind {
40514073 Use ( ..) | Static ( ..) | Const ( ..) | ConstBlock ( ..) | Fn ( ..) | Mod ( ..)
40524074 | GlobalAsm ( ..) | TyAlias ( ..) | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..)
40534075 | MacroDef ( ..) | Delegation ( ..) | DelegationMac ( ..) => "a" ,
4054- ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
4076+ ExternCrate ( ..)
4077+ | ForeignMod ( ..)
4078+ | MacCall ( ..)
4079+ | Enum ( ..)
4080+ | Impl { .. }
4081+ | AutoImpl ( ..)
4082+ | ExternImpl ( ..) => "an" ,
40554083 }
40564084 }
40574085
@@ -4075,6 +4103,8 @@ impl ItemKind {
40754103 ItemKind :: MacCall ( ..) => "item macro invocation" ,
40764104 ItemKind :: MacroDef ( ..) => "macro definition" ,
40774105 ItemKind :: Impl { .. } => "implementation" ,
4106+ ItemKind :: AutoImpl { .. } => "`auto` implementation" ,
4107+ ItemKind :: ExternImpl { .. } => "`extern` implementation" ,
40784108 ItemKind :: Delegation ( ..) => "delegated function" ,
40794109 ItemKind :: DelegationMac ( ..) => "delegation" ,
40804110 }
@@ -4090,6 +4120,8 @@ impl ItemKind {
40904120 | Self :: Union ( _, generics, _)
40914121 | Self :: Trait ( box Trait { generics, .. } )
40924122 | Self :: TraitAlias ( box TraitAlias { generics, .. } )
4123+ | Self :: AutoImpl ( box AutoImpl { generics, .. } )
4124+ | Self :: ExternImpl ( box ExternImpl { generics, .. } )
40934125 | Self :: Impl ( Impl { generics, .. } ) => Some ( generics) ,
40944126
40954127 Self :: ExternCrate ( ..)
@@ -4133,6 +4165,10 @@ pub enum AssocItemKind {
41334165 Delegation ( Box < Delegation > ) ,
41344166 /// An associated list or glob delegation item.
41354167 DelegationMac ( Box < DelegationMac > ) ,
4168+ /// An `auto impl` item
4169+ AutoImpl ( Box < AutoImpl > ) ,
4170+ /// An `extern impl` item
4171+ ExternImpl ( Box < ExternImpl > ) ,
41364172}
41374173
41384174impl AssocItemKind {
@@ -4143,15 +4179,26 @@ impl AssocItemKind {
41434179 | AssocItemKind :: Type ( box TyAlias { ident, .. } )
41444180 | AssocItemKind :: Delegation ( box Delegation { ident, .. } ) => Some ( ident) ,
41454181
4146- AssocItemKind :: MacCall ( _) | AssocItemKind :: DelegationMac ( _) => None ,
4182+ AssocItemKind :: MacCall ( _)
4183+ | AssocItemKind :: DelegationMac ( _)
4184+ | AssocItemKind :: AutoImpl ( _)
4185+ | AssocItemKind :: ExternImpl ( _) => None ,
41474186 }
41484187 }
41494188
41504189 pub fn defaultness ( & self ) -> Defaultness {
41514190 match * self {
41524191 Self :: Const ( box ConstItem { defaultness, .. } )
41534192 | Self :: Fn ( box Fn { defaultness, .. } )
4154- | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
4193+ | Self :: Type ( box TyAlias { defaultness, .. } )
4194+ | Self :: AutoImpl ( box AutoImpl {
4195+ of_trait : box TraitImplHeader { defaultness, .. } ,
4196+ ..
4197+ } )
4198+ | Self :: ExternImpl ( box ExternImpl {
4199+ of_trait : box TraitImplHeader { defaultness, .. } ,
4200+ ..
4201+ } ) => defaultness,
41554202 Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
41564203 Defaultness :: Implicit
41574204 }
@@ -4168,6 +4215,8 @@ impl From<AssocItemKind> for ItemKind {
41684215 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
41694216 AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
41704217 AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
4218+ AssocItemKind :: AutoImpl ( ai) => ItemKind :: AutoImpl ( ai) ,
4219+ AssocItemKind :: ExternImpl ( ei) => ItemKind :: ExternImpl ( ei) ,
41714220 }
41724221 }
41734222}
@@ -4183,6 +4232,8 @@ impl TryFrom<ItemKind> for AssocItemKind {
41834232 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
41844233 ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
41854234 ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
4235+ ItemKind :: AutoImpl ( ai) => AssocItemKind :: AutoImpl ( ai) ,
4236+ ItemKind :: ExternImpl ( ei) => AssocItemKind :: ExternImpl ( ei) ,
41864237 _ => return Err ( item_kind) ,
41874238 } )
41884239 }
0 commit comments