]> git.lizzy.rs Git - rust.git/commitdiff
refactor: minor parser cleanup
authorCaleb Cartwright <caleb.cartwright@outlook.com>
Sat, 30 Oct 2021 15:10:08 +0000 (10:10 -0500)
committerCaleb Cartwright <calebcartwright@users.noreply.github.com>
Sat, 30 Oct 2021 16:00:19 +0000 (11:00 -0500)
src/syntux/parser.rs

index 14b92238cfa6c66917d5cf5835f3e9040146fefa..d1bb2f80004aa08461ddf0306bf2285130f80e35 100644 (file)
@@ -125,18 +125,12 @@ pub(crate) fn parse_file_as_module(
             }
         }));
         match result {
-            Ok(Some(m)) => {
-                if !sess.has_errors() {
-                    return Ok(m);
-                }
-
-                if sess.can_reset_errors() {
-                    sess.reset_errors();
-                    return Ok(m);
-                }
-                Err(ParserError::ParseError)
+            Ok(Some(m)) if !sess.has_errors() => Ok(m),
+            Ok(Some(m)) if sess.can_reset_errors() => {
+                sess.reset_errors();
+                Ok(m)
             }
-            Ok(None) => Err(ParserError::ParseError),
+            Ok(_) => Err(ParserError::ParseError),
             Err(..) if path.exists() => Err(ParserError::ParseError),
             Err(_) => Err(ParserError::ParsePanicError),
         }