]> git.lizzy.rs Git - rust.git/commitdiff
libsyntax: remove panics from Parser::parse_pat_nopanic
authorKevin Butler <haqkrs@gmail.com>
Sun, 25 Oct 2015 00:02:08 +0000 (01:02 +0100)
committerKevin Butler <haqkrs@gmail.com>
Sun, 25 Oct 2015 00:33:22 +0000 (01:33 +0100)
src/libsyntax/parse/parser.rs

index 092013a4753b55d138b9f35b67cfced573e38cfb..7bc9441fb9dbb716f0d79239485de67ec60dd38f 100644 (file)
@@ -3276,12 +3276,9 @@ pub fn parse_pat_nopanic(&mut self) -> PResult<P<Pat>> {
                       }
                       token::OpenDelim(token::Brace) => {
                          if qself.is_some() {
-                            let span = self.span;
-                            self.span_err(span,
-                                          "unexpected `{` after qualified path");
-                            self.abort_if_errors();
+                            return Err(self.fatal("unexpected `{` after qualified path"));
                         }
-                       // Parse struct pattern
+                        // Parse struct pattern
                         try!(self.bump());
                         let (fields, etc) = try!(self.parse_pat_fields());
                         try!(self.bump());
@@ -3289,10 +3286,7 @@ pub fn parse_pat_nopanic(&mut self) -> PResult<P<Pat>> {
                       }
                       token::OpenDelim(token::Paren) => {
                         if qself.is_some() {
-                            let span = self.span;
-                            self.span_err(span,
-                                          "unexpected `(` after qualified path");
-                            self.abort_if_errors();
+                            return Err(self.fatal("unexpected `(` after qualified path"));
                         }
                         // Parse tuple struct or enum pattern
                         if self.look_ahead(1, |t| *t == token::DotDot) {