@@ -8,6 +8,9 @@ use std::fmt;
88use std:: result;
99use std:: u8;
1010
11+ #[ cfg( feature = "arbitrary" ) ]
12+ use arbitrary:: Arbitrary ;
13+
1114use crate :: ast:: Span ;
1215use crate :: hir:: interval:: { Interval , IntervalSet , IntervalSetIter } ;
1316use crate :: unicode;
@@ -172,6 +175,7 @@ impl fmt::Display for ErrorKind {
172175/// expression pattern string, and uses constant stack space and heap space
173176/// proportional to the size of the `Hir`.
174177#[ derive( Clone , Debug , Eq , PartialEq ) ]
178+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
175179pub struct Hir {
176180 /// The underlying HIR kind.
177181 kind : HirKind ,
@@ -181,6 +185,7 @@ pub struct Hir {
181185
182186/// The kind of an arbitrary `Hir` expression.
183187#[ derive( Clone , Debug , Eq , PartialEq ) ]
188+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
184189pub enum HirKind {
185190 /// The empty regular expression, which matches everything, including the
186191 /// empty string.
@@ -744,6 +749,7 @@ impl fmt::Display for Hir {
744749/// are preferred whenever possible. In particular, a `Byte` variant is only
745750/// ever produced when it could match invalid UTF-8.
746751#[ derive( Clone , Debug , Eq , PartialEq ) ]
752+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
747753pub enum Literal {
748754 /// A single character represented by a Unicode scalar value.
749755 Unicode ( char ) ,
@@ -780,6 +786,7 @@ impl Literal {
780786/// case insensitive matching. For example, `(?i)k` and `(?i-u)k` will not
781787/// match the same set of strings.
782788#[ derive( Clone , Debug , Eq , PartialEq ) ]
789+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
783790pub enum Class {
784791 /// A set of characters represented by Unicode scalar values.
785792 Unicode ( ClassUnicode ) ,
@@ -834,6 +841,7 @@ impl Class {
834841
835842/// A set of characters represented by Unicode scalar values.
836843#[ derive( Clone , Debug , Eq , PartialEq ) ]
844+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
837845pub struct ClassUnicode {
838846 set : IntervalSet < ClassUnicodeRange > ,
839847}
@@ -970,6 +978,7 @@ impl<'a> Iterator for ClassUnicodeIter<'a> {
970978/// The range is closed. That is, the start and end of the range are included
971979/// in the range.
972980#[ derive( Clone , Copy , Default , Eq , PartialEq , PartialOrd , Ord ) ]
981+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
973982pub struct ClassUnicodeRange {
974983 start : char ,
975984 end : char ,
@@ -1077,6 +1086,7 @@ impl ClassUnicodeRange {
10771086/// A set of characters represented by arbitrary bytes (where one byte
10781087/// corresponds to one character).
10791088#[ derive( Clone , Debug , Eq , PartialEq ) ]
1089+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
10801090pub struct ClassBytes {
10811091 set : IntervalSet < ClassBytesRange > ,
10821092}
@@ -1187,6 +1197,7 @@ impl<'a> Iterator for ClassBytesIter<'a> {
11871197/// The range is closed. That is, the start and end of the range are included
11881198/// in the range.
11891199#[ derive( Clone , Copy , Default , Eq , PartialEq , PartialOrd , Ord ) ]
1200+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
11901201pub struct ClassBytesRange {
11911202 start : u8 ,
11921203 end : u8 ,
@@ -1282,6 +1293,7 @@ impl fmt::Debug for ClassBytesRange {
12821293///
12831294/// A matching anchor assertion is always zero-length.
12841295#[ derive( Clone , Debug , Eq , PartialEq ) ]
1296+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
12851297pub enum Anchor {
12861298 /// Match the beginning of a line or the beginning of text. Specifically,
12871299 /// this matches at the starting position of the input, or at the position
@@ -1303,6 +1315,7 @@ pub enum Anchor {
13031315///
13041316/// A matching word boundary assertion is always zero-length.
13051317#[ derive( Clone , Debug , Eq , PartialEq ) ]
1318+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
13061319pub enum WordBoundary {
13071320 /// Match a Unicode-aware word boundary. That is, this matches a position
13081321 /// where the left adjacent character and right adjacent character
@@ -1336,6 +1349,7 @@ impl WordBoundary {
13361349/// 2. A capturing group (e.g., `(expr)`).
13371350/// 3. A named capturing group (e.g., `(?P<name>expr)`).
13381351#[ derive( Clone , Debug , Eq , PartialEq ) ]
1352+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
13391353pub struct Group {
13401354 /// The kind of this group. If it is a capturing group, then the kind
13411355 /// contains the capture group index (and the name, if it is a named
@@ -1347,6 +1361,7 @@ pub struct Group {
13471361
13481362/// The kind of group.
13491363#[ derive( Clone , Debug , Eq , PartialEq ) ]
1364+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
13501365pub enum GroupKind {
13511366 /// A normal unnamed capturing group.
13521367 ///
@@ -1368,6 +1383,7 @@ pub enum GroupKind {
13681383/// A repetition operator permits the repetition of an arbitrary
13691384/// sub-expression.
13701385#[ derive( Clone , Debug , Eq , PartialEq ) ]
1386+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
13711387pub struct Repetition {
13721388 /// The kind of this repetition operator.
13731389 pub kind : RepetitionKind ,
@@ -1407,6 +1423,7 @@ impl Repetition {
14071423
14081424/// The kind of a repetition operator.
14091425#[ derive( Clone , Debug , Eq , PartialEq ) ]
1426+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
14101427pub enum RepetitionKind {
14111428 /// Matches a sub-expression zero or one times.
14121429 ZeroOrOne ,
@@ -1420,6 +1437,7 @@ pub enum RepetitionKind {
14201437
14211438/// The kind of a counted repetition operator.
14221439#[ derive( Clone , Debug , Eq , PartialEq ) ]
1440+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
14231441pub enum RepetitionRange {
14241442 /// Matches a sub-expression exactly this many times.
14251443 Exactly ( u32 ) ,
@@ -1477,6 +1495,7 @@ impl Drop for Hir {
14771495///
14781496/// These attributes are typically defined inductively on the HIR.
14791497#[ derive( Clone , Debug , Eq , PartialEq ) ]
1498+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
14801499struct HirInfo {
14811500 /// Represent yes/no questions by a bitfield to conserve space, since
14821501 /// this is included in every HIR expression.
0 commit comments