@@ -3733,29 +3733,7 @@ impl Item {
37333733 }
37343734
37353735 pub fn opt_generics ( & self ) -> Option < & Generics > {
3736- match & self . kind {
3737- ItemKind :: ExternCrate ( ..)
3738- | ItemKind :: ConstBlock ( _)
3739- | ItemKind :: Use ( _)
3740- | ItemKind :: Mod ( ..)
3741- | ItemKind :: ForeignMod ( _)
3742- | ItemKind :: GlobalAsm ( _)
3743- | ItemKind :: MacCall ( _)
3744- | ItemKind :: Delegation ( _)
3745- | ItemKind :: DelegationMac ( _)
3746- | ItemKind :: MacroDef ( ..) => None ,
3747- ItemKind :: Static ( _) => None ,
3748- ItemKind :: Const ( i) => Some ( & i. generics ) ,
3749- ItemKind :: Fn ( i) => Some ( & i. generics ) ,
3750- ItemKind :: TyAlias ( i) => Some ( & i. generics ) ,
3751- ItemKind :: TraitAlias ( i) => Some ( & i. generics ) ,
3752-
3753- ItemKind :: Enum ( _, generics, _)
3754- | ItemKind :: Struct ( _, generics, _)
3755- | ItemKind :: Union ( _, generics, _) => Some ( & generics) ,
3756- ItemKind :: Trait ( i) => Some ( & i. generics ) ,
3757- ItemKind :: Impl ( i) => Some ( & i. generics ) ,
3758- }
3736+ self . kind . generics ( )
37593737 }
37603738}
37613739
@@ -4092,6 +4070,57 @@ impl Guard {
40924070 }
40934071}
40944072
4073+ #[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
4074+ pub struct TestBinderConstraints {
4075+ pub generics : Generics ,
4076+ pub body : Box < TestBinderBody > ,
4077+ }
4078+
4079+ #[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
4080+ pub struct TestBinderBody {
4081+ pub foralls : ThinVec < TestBinderForall > ,
4082+ pub exists : ThinVec < TestBinderExists > ,
4083+ pub constraints : Vec < TestBinderConstraint > ,
4084+ }
4085+
4086+ #[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
4087+ pub struct TestBinderForall {
4088+ pub span : Span ,
4089+ pub node_id : NodeId ,
4090+ pub generics : Generics ,
4091+ pub body : TestBinderBody ,
4092+ pub assert_on_exit : Option < ThinVec < TestBinderConstraint > > ,
4093+ }
4094+
4095+ #[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
4096+ pub struct TestBinderExists {
4097+ pub span : Span ,
4098+ pub node_id : NodeId ,
4099+ pub params : ThinVec < GenericParam > ,
4100+ pub body : TestBinderBody ,
4101+ }
4102+
4103+ #[ derive( Clone , Encodable , Decodable , Debug , Walkable ) ]
4104+ pub enum TestBinderConstraint {
4105+ And {
4106+ items : ThinVec < TestBinderConstraint > ,
4107+ } ,
4108+ Or {
4109+ items : ThinVec < TestBinderConstraint > ,
4110+ } ,
4111+ Lifetime {
4112+ #[ visitable( extra = LifetimeCtxt :: Bound ) ]
4113+ lhs : Lifetime ,
4114+ #[ visitable( extra = LifetimeCtxt :: Bound ) ]
4115+ rhs : Lifetime ,
4116+ } ,
4117+ Type {
4118+ lhs : Box < Ty > ,
4119+ #[ visitable( extra = LifetimeCtxt :: Bound ) ]
4120+ rhs : Lifetime ,
4121+ } ,
4122+ }
4123+
40954124// Adding a new variant? Please update `test_item` in `tests/ui/macros/stringify.rs`.
40964125#[ derive( Clone , Encodable , Decodable , Debug ) ]
40974126pub enum ItemKind {
@@ -4173,6 +4202,8 @@ pub enum ItemKind {
41734202 /// A list or glob delegation item (`reuse prefix::{a, b, c}`, `reuse prefix::*`).
41744203 /// Treated similarly to a macro call and expanded early.
41754204 DelegationMac ( Box < DelegationMac > ) ,
4205+ /// A `test_binder_constraints!()`. Perma-unstable, used only for rustc tests.
4206+ TestBinderConstraints ( Box < TestBinderConstraints > ) ,
41764207}
41774208
41784209impl ItemKind {
@@ -4199,17 +4230,31 @@ impl ItemKind {
41994230 | ItemKind :: GlobalAsm ( _)
42004231 | ItemKind :: Impl ( _)
42014232 | ItemKind :: MacCall ( _)
4202- | ItemKind :: DelegationMac ( _) => None ,
4233+ | ItemKind :: DelegationMac ( _)
4234+ | ItemKind :: TestBinderConstraints ( _) => None ,
42034235 }
42044236 }
42054237
42064238 /// "a" or "an"
42074239 pub fn article ( & self ) -> & ' static str {
42084240 use ItemKind :: * ;
42094241 match self {
4210- Use ( ..) | Static ( ..) | Const ( ..) | ConstBlock ( ..) | Fn ( ..) | Mod ( ..)
4211- | GlobalAsm ( ..) | TyAlias ( ..) | Struct ( ..) | Union ( ..) | Trait ( ..) | TraitAlias ( ..)
4212- | MacroDef ( ..) | Delegation ( ..) | DelegationMac ( ..) => "a" ,
4242+ Use ( ..)
4243+ | Static ( ..)
4244+ | Const ( ..)
4245+ | ConstBlock ( ..)
4246+ | Fn ( ..)
4247+ | Mod ( ..)
4248+ | GlobalAsm ( ..)
4249+ | TyAlias ( ..)
4250+ | Struct ( ..)
4251+ | Union ( ..)
4252+ | Trait ( ..)
4253+ | TraitAlias ( ..)
4254+ | MacroDef ( ..)
4255+ | Delegation ( ..)
4256+ | DelegationMac ( ..)
4257+ | TestBinderConstraints ( ..) => "a" ,
42134258 ExternCrate ( ..) | ForeignMod ( ..) | MacCall ( ..) | Enum ( ..) | Impl { .. } => "an" ,
42144259 }
42154260 }
@@ -4236,6 +4281,7 @@ impl ItemKind {
42364281 ItemKind :: Impl { .. } => "implementation" ,
42374282 ItemKind :: Delegation ( ..) => "delegated function" ,
42384283 ItemKind :: DelegationMac ( ..) => "delegation" ,
4284+ ItemKind :: TestBinderConstraints ( ..) => "test_binder_constraints!" ,
42394285 }
42404286 }
42414287
@@ -4249,7 +4295,8 @@ impl ItemKind {
42494295 | Self :: Union ( _, generics, _)
42504296 | Self :: Trait ( Trait { generics, .. } )
42514297 | Self :: TraitAlias ( TraitAlias { generics, .. } )
4252- | Self :: Impl ( Impl { generics, .. } ) => Some ( generics) ,
4298+ | Self :: Impl ( Impl { generics, .. } )
4299+ | Self :: TestBinderConstraints ( TestBinderConstraints { generics, .. } ) => Some ( generics) ,
42534300
42544301 Self :: ExternCrate ( ..)
42554302 | Self :: Use ( ..)
0 commit comments