@@ -4341,13 +4341,14 @@ impl<'hir> Item<'hir> {
43414341 Constness ,
43424342 IsAuto ,
43434343 Safety ,
4344+ & ' hir ImplRestriction <' hir>,
43444345 Ident ,
43454346 & ' hir Generics <' hir>,
43464347 GenericBounds <' hir>,
43474348 & ' hir [ TraitItemId ]
43484349 ) ,
4349- ItemKind :: Trait ( constness, is_auto, safety, ident, generics, bounds, items) ,
4350- ( * constness, * is_auto, * safety, * ident, generics, bounds, items) ;
4350+ ItemKind :: Trait ( constness, is_auto, safety, impl_restriction , ident, generics, bounds, items) ,
4351+ ( * constness, * is_auto, * safety, impl_restriction , * ident, generics, bounds, items) ;
43514352
43524353 expect_trait_alias, ( Constness , Ident , & ' hir Generics <' hir>, GenericBounds <' hir>) ,
43534354 ItemKind :: TraitAlias ( constness, ident, generics, bounds) , ( * constness, * ident, generics, bounds) ;
@@ -4416,6 +4417,20 @@ impl fmt::Display for Constness {
44164417 }
44174418}
44184419
4420+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
4421+ pub struct ImplRestriction < ' hir > {
4422+ pub kind : RestrictionKind < ' hir > ,
4423+ pub span : Span ,
4424+ }
4425+
4426+ #[ derive( Debug , Clone , Copy , HashStable_Generic ) ]
4427+ pub enum RestrictionKind < ' hir > {
4428+ /// The restriction does not affect the item.
4429+ Unrestricted ,
4430+ /// The restriction only applies outside of this path.
4431+ Restricted ( & ' hir Path < ' hir , DefId > ) ,
4432+ }
4433+
44194434/// The actual safety specified in syntax. We may treat
44204435/// its safety different within the type system to create a
44214436/// "sound by default" system that needs checking this enum
@@ -4528,6 +4543,7 @@ pub enum ItemKind<'hir> {
45284543 Constness ,
45294544 IsAuto ,
45304545 Safety ,
4546+ & ' hir ImplRestriction < ' hir > ,
45314547 Ident ,
45324548 & ' hir Generics < ' hir > ,
45334549 GenericBounds < ' hir > ,
@@ -4578,7 +4594,7 @@ impl ItemKind<'_> {
45784594 | ItemKind :: Enum ( ident, ..)
45794595 | ItemKind :: Struct ( ident, ..)
45804596 | ItemKind :: Union ( ident, ..)
4581- | ItemKind :: Trait ( _, _, _, ident, ..)
4597+ | ItemKind :: Trait ( _, _, _, _ , ident, ..)
45824598 | ItemKind :: TraitAlias ( _, ident, ..) => Some ( ident) ,
45834599
45844600 ItemKind :: Use ( _, UseKind :: Glob | UseKind :: ListStem )
@@ -4596,7 +4612,7 @@ impl ItemKind<'_> {
45964612 | ItemKind :: Enum ( _, generics, _)
45974613 | ItemKind :: Struct ( _, generics, _)
45984614 | ItemKind :: Union ( _, generics, _)
4599- | ItemKind :: Trait ( _, _, _, _, generics, _, _)
4615+ | ItemKind :: Trait ( _, _, _, _, _ , generics, _, _)
46004616 | ItemKind :: TraitAlias ( _, _, generics, _)
46014617 | ItemKind :: Impl ( Impl { generics, .. } ) => generics,
46024618 _ => return None ,
0 commit comments