Simplify parsing by expecting the tokens stream will never be exhausted.

This commit is contained in:
Stephen Chung
2020-04-23 13:24:24 +08:00
parent a4bf572d5a
commit 5aaaa7be3b
3 changed files with 91 additions and 103 deletions

View File

@@ -178,7 +178,7 @@ fn optimize_stmt<'a>(stmt: Stmt, state: &mut State<'a>, preserve_result: bool) -
Box::new(optimize_expr(expr, state)),
Box::new(optimize_stmt(*if_block, state, true)),
match optimize_stmt(*else_block, state, true) {
stmt if matches!(stmt, Stmt::Noop(_)) => None, // Noop -> no else block
Stmt::Noop(_) => None, // Noop -> no else block
stmt => Some(Box::new(stmt)),
},
),