@@ -426,9 +426,9 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
426426 /// If the capture limit is exceeded, then an error is returned.
427427 fn next_capture_index ( & self , span : Span ) -> Result < u32 > {
428428 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 ( || {
430430 self . error ( span, ast:: ErrorKind :: CaptureLimitExceeded )
431- } ) ) ;
431+ } ) ? ;
432432 self . parser ( ) . capture_index . set ( i) ;
433433 Ok ( i)
434434 }
@@ -695,7 +695,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
695695 /// is returned.
696696 fn push_group ( & self , mut concat : ast:: Concat ) -> Result < ast:: Concat > {
697697 assert_eq ! ( self . char ( ) , '(' ) ;
698- match try! ( self . parse_group ( ) ) {
698+ match self . parse_group ( ) ? {
699699 Either :: Left ( set) => {
700700 let ignore = set. flags . flag_state ( ast:: Flag :: IgnoreWhitespace ) ;
701701 if let Some ( v) = ignore {
@@ -837,7 +837,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
837837 ) -> Result < ast:: ClassSetUnion > {
838838 assert_eq ! ( self . char ( ) , '[' ) ;
839839
840- let ( nested_set, nested_union) = try! ( self . parse_set_class_open ( ) ) ;
840+ let ( nested_set, nested_union) = self . parse_set_class_open ( ) ? ;
841841 self . parser ( ) . stack_class . borrow_mut ( ) . push ( ClassState :: Open {
842842 union : parent_union,
843843 set : nested_set,
@@ -987,33 +987,33 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
987987 break ;
988988 }
989989 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) ? ,
993993 '[' => {
994- let class = try! ( self . parse_set_class ( ) ) ;
994+ let class = self . parse_set_class ( ) ? ;
995995 concat. asts . push ( Ast :: Class ( class) ) ;
996996 }
997997 '?' => {
998- concat = try! ( self . parse_uncounted_repetition (
999- concat, ast:: RepetitionKind :: ZeroOrOne ) ) ;
998+ concat = self . parse_uncounted_repetition (
999+ concat, ast:: RepetitionKind :: ZeroOrOne ) ? ;
10001000 }
10011001 '*' => {
1002- concat = try! ( self . parse_uncounted_repetition (
1003- concat, ast:: RepetitionKind :: ZeroOrMore ) ) ;
1002+ concat = self . parse_uncounted_repetition (
1003+ concat, ast:: RepetitionKind :: ZeroOrMore ) ? ;
10041004 }
10051005 '+' => {
1006- concat = try! ( self . parse_uncounted_repetition (
1007- concat, ast:: RepetitionKind :: OneOrMore ) ) ;
1006+ concat = self . parse_uncounted_repetition (
1007+ concat, ast:: RepetitionKind :: OneOrMore ) ? ;
10081008 }
10091009 '{' => {
1010- concat = try! ( self . parse_counted_repetition ( concat) ) ;
1010+ concat = self . parse_counted_repetition ( concat) ? ;
10111011 }
1012- _ => concat. asts . push ( try! ( self . parse_primitive ( ) ) . into_ast ( ) ) ,
1012+ _ => concat. asts . push ( self . parse_primitive ( ) ? . into_ast ( ) ) ,
10131013 }
10141014 }
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) ? ;
10171017 Ok ( ast:: WithComments {
10181018 ast : ast,
10191019 comments : mem:: replace (
@@ -1106,7 +1106,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
11061106 ast:: ErrorKind :: RepetitionCountUnclosed ,
11071107 ) ) ;
11081108 }
1109- let count_start = try! ( self . parse_decimal ( ) ) ;
1109+ let count_start = self . parse_decimal ( ) ? ;
11101110 let mut range = ast:: RepetitionRange :: Exactly ( count_start) ;
11111111 if self . is_eof ( ) {
11121112 return Err ( self . error (
@@ -1122,7 +1122,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
11221122 ) ) ;
11231123 }
11241124 if self . char ( ) != '}' {
1125- let count_end = try! ( self . parse_decimal ( ) ) ;
1125+ let count_end = self . parse_decimal ( ) ? ;
11261126 range = ast:: RepetitionRange :: Bounded ( count_start, count_end) ;
11271127 } else {
11281128 range = ast:: RepetitionRange :: AtLeast ( count_start) ;
@@ -1191,8 +1191,8 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
11911191 }
11921192 let inner_span = self . span ( ) ;
11931193 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) ? ;
11961196 Ok ( Either :: Right ( ast:: Group {
11971197 span : open_span,
11981198 kind : ast:: GroupKind :: CaptureName ( cap) ,
@@ -1205,7 +1205,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
12051205 ast:: ErrorKind :: GroupUnclosed ,
12061206 ) ) ;
12071207 }
1208- let flags = try! ( self . parse_flags ( ) ) ;
1208+ let flags = self . parse_flags ( ) ? ;
12091209 let char_end = self . char ( ) ;
12101210 self . bump ( ) ;
12111211 if char_end == ')' {
@@ -1230,7 +1230,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
12301230 } ) )
12311231 }
12321232 } else {
1233- let capture_index = try! ( self . next_capture_index ( open_span) ) ;
1233+ let capture_index = self . next_capture_index ( open_span) ? ;
12341234 Ok ( Either :: Right ( ast:: Group {
12351235 span : open_span,
12361236 kind : ast:: GroupKind :: CaptureIndex ( capture_index) ,
@@ -1291,7 +1291,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
12911291 name : name. to_string ( ) ,
12921292 index : capture_index,
12931293 } ;
1294- try! ( self . add_capture_name ( & capname) ) ;
1294+ self . add_capture_name ( & capname) ? ;
12951295 Ok ( capname)
12961296 }
12971297
@@ -1334,7 +1334,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
13341334 last_was_negation = None ;
13351335 let item = ast:: FlagsItem {
13361336 span : self . span_char ( ) ,
1337- kind : ast:: FlagsItemKind :: Flag ( try! ( self . parse_flag ( ) ) ) ,
1337+ kind : ast:: FlagsItemKind :: Flag ( self . parse_flag ( ) ? ) ,
13381338 } ;
13391339 if let Some ( i) = flags. add_item ( item) {
13401340 return Err ( self . error (
@@ -1460,12 +1460,12 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
14601460 ) ) ;
14611461 }
14621462 'x' | 'u' | 'U' => {
1463- let mut lit = try! ( self . parse_hex ( ) ) ;
1463+ let mut lit = self . parse_hex ( ) ? ;
14641464 lit. span . start = start;
14651465 return Ok ( Primitive :: Literal ( lit) ) ;
14661466 }
14671467 'p' | 'P' => {
1468- let mut cls = try! ( self . parse_unicode_class ( ) ) ;
1468+ let mut cls = self . parse_unicode_class ( ) ? ;
14691469 cls. span . start = start;
14701470 return Ok ( Primitive :: Unicode ( cls) ) ;
14711471 }
@@ -1756,10 +1756,10 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
17561756 continue ;
17571757 }
17581758 }
1759- union = try! ( self . push_class_open ( union) ) ;
1759+ union = self . push_class_open ( union) ? ;
17601760 }
17611761 ']' => {
1762- match try! ( self . pop_class ( union) ) {
1762+ match self . pop_class ( union) ? {
17631763 Either :: Left ( nested_union) => { union = nested_union; }
17641764 Either :: Right ( class) => return Ok ( class) ,
17651765 }
@@ -1780,7 +1780,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
17801780 ast:: ClassSetBinaryOpKind :: SymmetricDifference , union) ;
17811781 }
17821782 _ => {
1783- union. push ( try! ( self . parse_set_class_range ( ) ) ) ;
1783+ union. push ( self . parse_set_class_range ( ) ? ) ;
17841784 }
17851785 }
17861786 }
@@ -1795,7 +1795,7 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
17951795 /// a simple literal is expected (e.g., in a range), then an error is
17961796 /// returned.
17971797 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 ( ) ? ;
17991799 self . bump_space ( ) ;
18001800 if self . is_eof ( ) {
18011801 return Err ( self . unclosed_class_error ( ) ) ;
@@ -1816,11 +1816,11 @@ impl<'s, P: Borrow<Parser>> ParserI<'s, P> {
18161816 if !self . bump_and_bump_space ( ) {
18171817 return Err ( self . unclosed_class_error ( ) ) ;
18181818 }
1819- let prim2 = try! ( self . parse_set_class_item ( ) ) ;
1819+ let prim2 = self . parse_set_class_item ( ) ? ;
18201820 let range = ast:: ClassSetRange {
18211821 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 ) ? ,
18241824 } ;
18251825 if !range. is_valid ( ) {
18261826 return Err ( self . error (
@@ -2121,10 +2121,10 @@ impl<'p, 's, P: Borrow<Parser>> NestLimiter<'p, 's, P> {
21212121 }
21222122
21232123 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 (
21252125 span. clone ( ) ,
21262126 ast:: ErrorKind :: NestLimitExceeded ( :: std:: u32:: MAX ) ,
2127- ) ) ) ;
2127+ ) ) ? ;
21282128 let limit = self . p . parser ( ) . nest_limit ;
21292129 if new > limit {
21302130 return Err ( self . p . error (
0 commit comments