@@ -426,9 +426,9 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
426
426
/// If the capture limit is exceeded, then an error is returned.
427
427
fn next_capture_index ( & self , span : Span ) -> Result < u32 > {
428
428
let current = self . parser ( ) . capture_index . get ( ) ;
429
- let i = try! ( current. checked_add ( 1 ) . ok_or_else ( || {
429
+ let i = current. checked_add ( 1 ) . ok_or_else ( || {
430
430
self . error ( span, ast:: ErrorKind :: CaptureLimitExceeded )
431
- } ) ) ;
431
+ } ) ? ;
432
432
self . parser ( ) . capture_index . set ( i) ;
433
433
Ok ( i)
434
434
}
@@ -695,7 +695,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
695
695
/// is returned.
696
696
fn push_group ( & self , mut concat : ast:: Concat ) -> Result < ast:: Concat > {
697
697
assert_eq ! ( self . char ( ) , '(' ) ;
698
- match try! ( self . parse_group ( ) ) {
698
+ match self . parse_group ( ) ? {
699
699
Either :: Left ( set) => {
700
700
let ignore = set. flags . flag_state ( ast:: Flag :: IgnoreWhitespace ) ;
701
701
if let Some ( v) = ignore {
@@ -837,7 +837,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
837
837
) -> Result < ast:: ClassSetUnion > {
838
838
assert_eq ! ( self . char ( ) , '[' ) ;
839
839
840
- let ( nested_set, nested_union) = try! ( self . parse_set_class_open ( ) ) ;
840
+ let ( nested_set, nested_union) = self . parse_set_class_open ( ) ? ;
841
841
self . parser ( ) . stack_class . borrow_mut ( ) . push ( ClassState :: Open {
842
842
union : parent_union,
843
843
set : nested_set,
@@ -987,33 +987,33 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
987
987
break ;
988
988
}
989
989
match self . char ( ) {
990
- '(' => concat = try! ( self . push_group ( concat) ) ,
991
- ')' => concat = try! ( self . pop_group ( concat) ) ,
992
- '|' => concat = try! ( self . push_alternate ( concat) ) ,
990
+ '(' => concat = self . push_group ( concat) ? ,
991
+ ')' => concat = self . pop_group ( concat) ? ,
992
+ '|' => concat = self . push_alternate ( concat) ? ,
993
993
'[' => {
994
- let class = try! ( self . parse_set_class ( ) ) ;
994
+ let class = self . parse_set_class ( ) ? ;
995
995
concat. asts . push ( Ast :: Class ( class) ) ;
996
996
}
997
997
'?' => {
998
- concat = try! ( self . parse_uncounted_repetition (
999
- concat, ast:: RepetitionKind :: ZeroOrOne ) ) ;
998
+ concat = self . parse_uncounted_repetition (
999
+ concat, ast:: RepetitionKind :: ZeroOrOne ) ? ;
1000
1000
}
1001
1001
'*' => {
1002
- concat = try! ( self . parse_uncounted_repetition (
1003
- concat, ast:: RepetitionKind :: ZeroOrMore ) ) ;
1002
+ concat = self . parse_uncounted_repetition (
1003
+ concat, ast:: RepetitionKind :: ZeroOrMore ) ? ;
1004
1004
}
1005
1005
'+' => {
1006
- concat = try! ( self . parse_uncounted_repetition (
1007
- concat, ast:: RepetitionKind :: OneOrMore ) ) ;
1006
+ concat = self . parse_uncounted_repetition (
1007
+ concat, ast:: RepetitionKind :: OneOrMore ) ? ;
1008
1008
}
1009
1009
'{' => {
1010
- concat = try! ( self . parse_counted_repetition ( concat) ) ;
1010
+ concat = self . parse_counted_repetition ( concat) ? ;
1011
1011
}
1012
- _ => concat. asts . push ( try! ( self . parse_primitive ( ) ) . into_ast ( ) ) ,
1012
+ _ => concat. asts . push ( self . parse_primitive ( ) ? . into_ast ( ) ) ,
1013
1013
}
1014
1014
}
1015
- let ast = try! ( self . pop_group_end ( concat) ) ;
1016
- try! ( NestLimiter :: new ( self ) . check ( & ast) ) ;
1015
+ let ast = self . pop_group_end ( concat) ? ;
1016
+ NestLimiter :: new ( self ) . check ( & ast) ? ;
1017
1017
Ok ( ast:: WithComments {
1018
1018
ast : ast,
1019
1019
comments : mem:: replace (
@@ -1106,7 +1106,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1106
1106
ast:: ErrorKind :: RepetitionCountUnclosed ,
1107
1107
) ) ;
1108
1108
}
1109
- let count_start = try! ( self . parse_decimal ( ) ) ;
1109
+ let count_start = self . parse_decimal ( ) ? ;
1110
1110
let mut range = ast:: RepetitionRange :: Exactly ( count_start) ;
1111
1111
if self . is_eof ( ) {
1112
1112
return Err ( self . error (
@@ -1122,7 +1122,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1122
1122
) ) ;
1123
1123
}
1124
1124
if self . char ( ) != '}' {
1125
- let count_end = try! ( self . parse_decimal ( ) ) ;
1125
+ let count_end = self . parse_decimal ( ) ? ;
1126
1126
range = ast:: RepetitionRange :: Bounded ( count_start, count_end) ;
1127
1127
} else {
1128
1128
range = ast:: RepetitionRange :: AtLeast ( count_start) ;
@@ -1191,8 +1191,8 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1191
1191
}
1192
1192
let inner_span = self . span ( ) ;
1193
1193
if self . bump_if ( "?P<" ) {
1194
- let capture_index = try! ( self . next_capture_index ( open_span) ) ;
1195
- let cap = try! ( self . parse_capture_name ( capture_index) ) ;
1194
+ let capture_index = self . next_capture_index ( open_span) ? ;
1195
+ let cap = self . parse_capture_name ( capture_index) ? ;
1196
1196
Ok ( Either :: Right ( ast:: Group {
1197
1197
span : open_span,
1198
1198
kind : ast:: GroupKind :: CaptureName ( cap) ,
@@ -1205,7 +1205,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1205
1205
ast:: ErrorKind :: GroupUnclosed ,
1206
1206
) ) ;
1207
1207
}
1208
- let flags = try! ( self . parse_flags ( ) ) ;
1208
+ let flags = self . parse_flags ( ) ? ;
1209
1209
let char_end = self . char ( ) ;
1210
1210
self . bump ( ) ;
1211
1211
if char_end == ')' {
@@ -1230,7 +1230,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1230
1230
} ) )
1231
1231
}
1232
1232
} else {
1233
- let capture_index = try! ( self . next_capture_index ( open_span) ) ;
1233
+ let capture_index = self . next_capture_index ( open_span) ? ;
1234
1234
Ok ( Either :: Right ( ast:: Group {
1235
1235
span : open_span,
1236
1236
kind : ast:: GroupKind :: CaptureIndex ( capture_index) ,
@@ -1291,7 +1291,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1291
1291
name : name. to_string ( ) ,
1292
1292
index : capture_index,
1293
1293
} ;
1294
- try! ( self . add_capture_name ( & capname) ) ;
1294
+ self . add_capture_name ( & capname) ? ;
1295
1295
Ok ( capname)
1296
1296
}
1297
1297
@@ -1334,7 +1334,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1334
1334
last_was_negation = None ;
1335
1335
let item = ast:: FlagsItem {
1336
1336
span : self . span_char ( ) ,
1337
- kind : ast:: FlagsItemKind :: Flag ( try! ( self . parse_flag ( ) ) ) ,
1337
+ kind : ast:: FlagsItemKind :: Flag ( self . parse_flag ( ) ? ) ,
1338
1338
} ;
1339
1339
if let Some ( i) = flags. add_item ( item) {
1340
1340
return Err ( self . error (
@@ -1460,12 +1460,12 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1460
1460
) ) ;
1461
1461
}
1462
1462
'x' | 'u' | 'U' => {
1463
- let mut lit = try! ( self . parse_hex ( ) ) ;
1463
+ let mut lit = self . parse_hex ( ) ? ;
1464
1464
lit. span . start = start;
1465
1465
return Ok ( Primitive :: Literal ( lit) ) ;
1466
1466
}
1467
1467
'p' | 'P' => {
1468
- let mut cls = try! ( self . parse_unicode_class ( ) ) ;
1468
+ let mut cls = self . parse_unicode_class ( ) ? ;
1469
1469
cls. span . start = start;
1470
1470
return Ok ( Primitive :: Unicode ( cls) ) ;
1471
1471
}
@@ -1756,10 +1756,10 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1756
1756
continue ;
1757
1757
}
1758
1758
}
1759
- union = try! ( self . push_class_open ( union) ) ;
1759
+ union = self . push_class_open ( union) ? ;
1760
1760
}
1761
1761
']' => {
1762
- match try! ( self . pop_class ( union) ) {
1762
+ match self . pop_class ( union) ? {
1763
1763
Either :: Left ( nested_union) => { union = nested_union; }
1764
1764
Either :: Right ( class) => return Ok ( class) ,
1765
1765
}
@@ -1780,7 +1780,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1780
1780
ast:: ClassSetBinaryOpKind :: SymmetricDifference , union) ;
1781
1781
}
1782
1782
_ => {
1783
- union. push ( try! ( self . parse_set_class_range ( ) ) ) ;
1783
+ union. push ( self . parse_set_class_range ( ) ? ) ;
1784
1784
}
1785
1785
}
1786
1786
}
@@ -1795,7 +1795,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1795
1795
/// a simple literal is expected (e.g., in a range), then an error is
1796
1796
/// returned.
1797
1797
fn parse_set_class_range ( & self ) -> Result < ast:: ClassSetItem > {
1798
- let prim1 = try! ( self . parse_set_class_item ( ) ) ;
1798
+ let prim1 = self . parse_set_class_item ( ) ? ;
1799
1799
self . bump_space ( ) ;
1800
1800
if self . is_eof ( ) {
1801
1801
return Err ( self . unclosed_class_error ( ) ) ;
@@ -1816,11 +1816,11 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
1816
1816
if !self . bump_and_bump_space ( ) {
1817
1817
return Err ( self . unclosed_class_error ( ) ) ;
1818
1818
}
1819
- let prim2 = try! ( self . parse_set_class_item ( ) ) ;
1819
+ let prim2 = self . parse_set_class_item ( ) ? ;
1820
1820
let range = ast:: ClassSetRange {
1821
1821
span : Span :: new ( prim1. span ( ) . start , prim2. span ( ) . end ) ,
1822
- start : try! ( prim1. into_class_literal ( self ) ) ,
1823
- end : try! ( prim2. into_class_literal ( self ) ) ,
1822
+ start : prim1. into_class_literal ( self ) ? ,
1823
+ end : prim2. into_class_literal ( self ) ? ,
1824
1824
} ;
1825
1825
if !range. is_valid ( ) {
1826
1826
return Err ( self . error (
@@ -2121,10 +2121,10 @@ impl<'p, 's, P: Borrow<Parser>> NestLimiter<'p, 's, P> {
2121
2121
}
2122
2122
2123
2123
fn increment_depth ( & mut self , span : & Span ) -> Result < ( ) > {
2124
- let new = try! ( self . depth . checked_add ( 1 ) . ok_or_else ( || self . p . error (
2124
+ let new = self . depth . checked_add ( 1 ) . ok_or_else ( || self . p . error (
2125
2125
span. clone ( ) ,
2126
2126
ast:: ErrorKind :: NestLimitExceeded ( :: std:: u32:: MAX ) ,
2127
- ) ) ) ;
2127
+ ) ) ? ;
2128
2128
let limit = self . p . parser ( ) . nest_limit ;
2129
2129
if new > limit {
2130
2130
return Err ( self . p . error (
0 commit comments