@@ -8,6 +8,9 @@ use std::fmt;
8
8
use std:: result;
9
9
use std:: u8;
10
10
11
+ #[ cfg( feature = "arbitrary" ) ]
12
+ use arbitrary:: Arbitrary ;
13
+
11
14
use crate :: ast:: Span ;
12
15
use crate :: hir:: interval:: { Interval , IntervalSet , IntervalSetIter } ;
13
16
use crate :: unicode;
@@ -172,6 +175,7 @@ impl fmt::Display for ErrorKind {
172
175
/// expression pattern string, and uses constant stack space and heap space
173
176
/// proportional to the size of the `Hir`.
174
177
#[ derive( Clone , Debug , Eq , PartialEq ) ]
178
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
175
179
pub struct Hir {
176
180
/// The underlying HIR kind.
177
181
kind : HirKind ,
@@ -181,6 +185,7 @@ pub struct Hir {
181
185
182
186
/// The kind of an arbitrary `Hir` expression.
183
187
#[ derive( Clone , Debug , Eq , PartialEq ) ]
188
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
184
189
pub enum HirKind {
185
190
/// The empty regular expression, which matches everything, including the
186
191
/// empty string.
@@ -744,6 +749,7 @@ impl fmt::Display for Hir {
744
749
/// are preferred whenever possible. In particular, a `Byte` variant is only
745
750
/// ever produced when it could match invalid UTF-8.
746
751
#[ derive( Clone , Debug , Eq , PartialEq ) ]
752
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
747
753
pub enum Literal {
748
754
/// A single character represented by a Unicode scalar value.
749
755
Unicode ( char ) ,
@@ -780,6 +786,7 @@ impl Literal {
780
786
/// case insensitive matching. For example, `(?i)k` and `(?i-u)k` will not
781
787
/// match the same set of strings.
782
788
#[ derive( Clone , Debug , Eq , PartialEq ) ]
789
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
783
790
pub enum Class {
784
791
/// A set of characters represented by Unicode scalar values.
785
792
Unicode ( ClassUnicode ) ,
@@ -834,6 +841,7 @@ impl Class {
834
841
835
842
/// A set of characters represented by Unicode scalar values.
836
843
#[ derive( Clone , Debug , Eq , PartialEq ) ]
844
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
837
845
pub struct ClassUnicode {
838
846
set : IntervalSet < ClassUnicodeRange > ,
839
847
}
@@ -970,6 +978,7 @@ impl<'a> Iterator for ClassUnicodeIter<'a> {
970
978
/// The range is closed. That is, the start and end of the range are included
971
979
/// in the range.
972
980
#[ derive( Clone , Copy , Default , Eq , PartialEq , PartialOrd , Ord ) ]
981
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
973
982
pub struct ClassUnicodeRange {
974
983
start : char ,
975
984
end : char ,
@@ -1077,6 +1086,7 @@ impl ClassUnicodeRange {
1077
1086
/// A set of characters represented by arbitrary bytes (where one byte
1078
1087
/// corresponds to one character).
1079
1088
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1089
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1080
1090
pub struct ClassBytes {
1081
1091
set : IntervalSet < ClassBytesRange > ,
1082
1092
}
@@ -1187,6 +1197,7 @@ impl<'a> Iterator for ClassBytesIter<'a> {
1187
1197
/// The range is closed. That is, the start and end of the range are included
1188
1198
/// in the range.
1189
1199
#[ derive( Clone , Copy , Default , Eq , PartialEq , PartialOrd , Ord ) ]
1200
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1190
1201
pub struct ClassBytesRange {
1191
1202
start : u8 ,
1192
1203
end : u8 ,
@@ -1282,6 +1293,7 @@ impl fmt::Debug for ClassBytesRange {
1282
1293
///
1283
1294
/// A matching anchor assertion is always zero-length.
1284
1295
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1296
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1285
1297
pub enum Anchor {
1286
1298
/// Match the beginning of a line or the beginning of text. Specifically,
1287
1299
/// this matches at the starting position of the input, or at the position
@@ -1303,6 +1315,7 @@ pub enum Anchor {
1303
1315
///
1304
1316
/// A matching word boundary assertion is always zero-length.
1305
1317
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1318
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1306
1319
pub enum WordBoundary {
1307
1320
/// Match a Unicode-aware word boundary. That is, this matches a position
1308
1321
/// where the left adjacent character and right adjacent character
@@ -1336,6 +1349,7 @@ impl WordBoundary {
1336
1349
/// 2. A capturing group (e.g., `(expr)`).
1337
1350
/// 3. A named capturing group (e.g., `(?P<name>expr)`).
1338
1351
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1352
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1339
1353
pub struct Group {
1340
1354
/// The kind of this group. If it is a capturing group, then the kind
1341
1355
/// contains the capture group index (and the name, if it is a named
@@ -1347,6 +1361,7 @@ pub struct Group {
1347
1361
1348
1362
/// The kind of group.
1349
1363
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1364
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1350
1365
pub enum GroupKind {
1351
1366
/// A normal unnamed capturing group.
1352
1367
///
@@ -1368,6 +1383,7 @@ pub enum GroupKind {
1368
1383
/// A repetition operator permits the repetition of an arbitrary
1369
1384
/// sub-expression.
1370
1385
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1386
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1371
1387
pub struct Repetition {
1372
1388
/// The kind of this repetition operator.
1373
1389
pub kind : RepetitionKind ,
@@ -1407,6 +1423,7 @@ impl Repetition {
1407
1423
1408
1424
/// The kind of a repetition operator.
1409
1425
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1426
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1410
1427
pub enum RepetitionKind {
1411
1428
/// Matches a sub-expression zero or one times.
1412
1429
ZeroOrOne ,
@@ -1420,6 +1437,7 @@ pub enum RepetitionKind {
1420
1437
1421
1438
/// The kind of a counted repetition operator.
1422
1439
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1440
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1423
1441
pub enum RepetitionRange {
1424
1442
/// Matches a sub-expression exactly this many times.
1425
1443
Exactly ( u32 ) ,
@@ -1477,6 +1495,7 @@ impl Drop for Hir {
1477
1495
///
1478
1496
/// These attributes are typically defined inductively on the HIR.
1479
1497
#[ derive( Clone , Debug , Eq , PartialEq ) ]
1498
+ #[ cfg_attr( feature = "arbitrary" , derive( Arbitrary ) ) ]
1480
1499
struct HirInfo {
1481
1500
/// Represent yes/no questions by a bitfield to conserve space, since
1482
1501
/// this is included in every HIR expression.
0 commit comments