Skip to content

Commit b003f10

Browse files
committed
Desugar while let into loop { match { ... } }
1 parent 0c2c811 commit b003f10

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/libsyntax/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,8 @@ pub struct QPath {
581581
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
582582
pub enum MatchSource {
583583
MatchNormal,
584-
MatchIfLetDesugar
584+
MatchIfLetDesugar,
585+
MatchWhileLetDesugar,
585586
}
586587

587588
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]

src/libsyntax/ext/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ pub trait AstBuilder {
147147
fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
148148
fn expr_none(&self, sp: Span) -> P<ast::Expr>;
149149

150+
fn expr_break(&self, sp: Span) -> P<ast::Expr>;
151+
150152
fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;
151153

152154
fn expr_fail(&self, span: Span, msg: InternedString) -> P<ast::Expr>;
@@ -688,6 +690,12 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
688690
self.expr_path(none)
689691
}
690692

693+
694+
fn expr_break(&self, sp: Span) -> P<ast::Expr> {
695+
self.expr(sp, ast::ExprBreak(None))
696+
}
697+
698+
691699
fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
692700
self.expr(sp, ast::ExprTup(exprs))
693701
}

0 commit comments

Comments
 (0)