refactor: minor parser cleanup

This commit is contained in:
Caleb Cartwright 2021-10-30 10:10:08 -05:00 committed by Caleb Cartwright
parent bc46af9742
commit ed5a0250d3

View file

@ -125,18 +125,12 @@ impl<'a> Parser<'a> {
}
}));
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),
}