@@ -3635,6 +3635,7 @@ impl Item {
36353635 | ItemKind :: DelegationMac ( _)
36363636 | ItemKind :: MacroDef ( ..) => None ,
36373637 ItemKind :: Static ( _) => None ,
3638+ ItemKind :: AutoImpl ( ai) => Some ( & ai. generics ) ,
36383639 ItemKind :: Const ( i) => Some ( & i. generics ) ,
36393640 ItemKind :: Fn ( i) => Some ( & i. generics ) ,
36403641 ItemKind :: TyAlias ( i) => Some ( & i. generics ) ,
@@ -3778,6 +3779,14 @@ pub struct Impl {
37783779 pub items : ThinVec < Box < AssocItem > > ,
37793780}
37803781
3782+ #[ derive( Clone , Encodable , Decodable , Debug ) ]
3783+ pub struct AutoImpl {
3784+ pub generics : Generics ,
3785+ pub constness : Const ,
3786+ pub of_trait : Box < TraitImplHeader > ,
3787+ pub items : ThinVec < Box < AssocItem > > ,
3788+ }
3789+
37813790#[ derive( Clone , Encodable , Decodable , Debug ) ]
37823791pub struct TraitImplHeader {
37833792 pub defaultness : Defaultness ,
@@ -3958,6 +3967,8 @@ pub enum ItemKind {
39583967 ///
39593968 /// E.g., `impl<A> Foo<A> { .. }` or `impl<A> Trait for Foo<A> { .. }`.
39603969 Impl ( Impl ) ,
3970+ /// An `auto impl` implementation, such as a supertrait `auto impl`.
3971+ AutoImpl ( Box < AutoImpl > ) ,
39613972 /// A macro invocation.
39623973 ///
39633974 /// E.g., `foo!(..)`.
@@ -3994,6 +4005,7 @@ impl ItemKind {
39944005 | ItemKind :: ForeignMod ( _)
39954006 | ItemKind :: GlobalAsm ( _)
39964007 | ItemKind :: Impl ( _)
4008+ | ItemKind :: AutoImpl ( _)
39974009 | ItemKind :: MacCall ( _)
39984010 | ItemKind :: DelegationMac ( _) => None ,
39994011 }
@@ -4006,7 +4018,12 @@ impl ItemKind {
40064018 Use ( ..) | Static ( ..) | Const ( ..) | Fn ( ..) | Mod ( ..) | GlobalAsm ( ..) | TyAlias ( ..)
40074019 | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..) | MacroDef ( ..)
40084020 | Delegation ( ..) | DelegationMac ( ..) => "a" ,
4009- ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
4021+ ExternCrate ( ..)
4022+ | ForeignMod ( ..)
4023+ | MacCall ( ..)
4024+ | Enum ( ..)
4025+ | Impl { .. }
4026+ | AutoImpl { .. } => "an" ,
40104027 }
40114028 }
40124029
@@ -4029,6 +4046,7 @@ impl ItemKind {
40294046 ItemKind :: MacCall ( ..) => "item macro invocation" ,
40304047 ItemKind :: MacroDef ( ..) => "macro definition" ,
40314048 ItemKind :: Impl { .. } => "implementation" ,
4049+ ItemKind :: AutoImpl { .. } => "`auto` implementation" ,
40324050 ItemKind :: Delegation ( ..) => "delegated function" ,
40334051 ItemKind :: DelegationMac ( ..) => "delegation" ,
40344052 }
@@ -4076,6 +4094,8 @@ pub enum AssocItemKind {
40764094 Delegation ( Box < Delegation > ) ,
40774095 /// An associated list or glob delegation item.
40784096 DelegationMac ( Box < DelegationMac > ) ,
4097+ /// An `auto impl` item
4098+ AutoImpl ( Box < AutoImpl > ) ,
40794099}
40804100
40814101impl AssocItemKind {
@@ -4086,15 +4106,21 @@ impl AssocItemKind {
40864106 | AssocItemKind :: Type ( box TyAlias { ident, .. } )
40874107 | AssocItemKind :: Delegation ( box Delegation { ident, .. } ) => Some ( ident) ,
40884108
4089- AssocItemKind :: MacCall ( _) | AssocItemKind :: DelegationMac ( _) => None ,
4109+ AssocItemKind :: MacCall ( _)
4110+ | AssocItemKind :: DelegationMac ( _)
4111+ | AssocItemKind :: AutoImpl ( _) => None ,
40904112 }
40914113 }
40924114
40934115 pub fn defaultness ( & self ) -> Defaultness {
40944116 match * self {
40954117 Self :: Const ( box ConstItem { defaultness, .. } )
40964118 | Self :: Fn ( box Fn { defaultness, .. } )
4097- | Self :: Type ( box TyAlias { defaultness, .. } ) => defaultness,
4119+ | Self :: Type ( box TyAlias { defaultness, .. } )
4120+ | Self :: AutoImpl ( box AutoImpl {
4121+ of_trait : box TraitImplHeader { defaultness, .. } ,
4122+ ..
4123+ } ) => defaultness,
40984124 Self :: MacCall ( ..) | Self :: Delegation ( ..) | Self :: DelegationMac ( ..) => {
40994125 Defaultness :: Final
41004126 }
@@ -4111,6 +4137,7 @@ impl From<AssocItemKind> for ItemKind {
41114137 AssocItemKind :: MacCall ( a) => ItemKind :: MacCall ( a) ,
41124138 AssocItemKind :: Delegation ( delegation) => ItemKind :: Delegation ( delegation) ,
41134139 AssocItemKind :: DelegationMac ( delegation) => ItemKind :: DelegationMac ( delegation) ,
4140+ AssocItemKind :: AutoImpl ( ai) => ItemKind :: AutoImpl ( ai) ,
41144141 }
41154142 }
41164143}
@@ -4126,6 +4153,7 @@ impl TryFrom<ItemKind> for AssocItemKind {
41264153 ItemKind :: MacCall ( a) => AssocItemKind :: MacCall ( a) ,
41274154 ItemKind :: Delegation ( d) => AssocItemKind :: Delegation ( d) ,
41284155 ItemKind :: DelegationMac ( d) => AssocItemKind :: DelegationMac ( d) ,
4156+ ItemKind :: AutoImpl ( ai) => AssocItemKind :: AutoImpl ( ai) ,
41294157 _ => return Err ( item_kind) ,
41304158 } )
41314159 }
0 commit comments