Skip to content

Commit

Permalink
Desugar while let into loop { match { ... } }
Browse files Browse the repository at this point in the history
  • Loading branch information
hydhknn committed Oct 11, 2014
1 parent 0c2c811 commit b003f10
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libsyntax/ast.rs
Expand Up @@ -581,7 +581,8 @@ pub struct QPath {
#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
pub enum MatchSource {
MatchNormal,
MatchIfLetDesugar
MatchIfLetDesugar,
MatchWhileLetDesugar,
}

#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)]
Expand Down
8 changes: 8 additions & 0 deletions src/libsyntax/ext/build.rs
Expand Up @@ -147,6 +147,8 @@ pub trait AstBuilder {
fn expr_some(&self, sp: Span, expr: P<ast::Expr>) -> P<ast::Expr>;
fn expr_none(&self, sp: Span) -> P<ast::Expr>;

fn expr_break(&self, sp: Span) -> P<ast::Expr>;

fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr>;

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


fn expr_break(&self, sp: Span) -> P<ast::Expr> {
self.expr(sp, ast::ExprBreak(None))
}


fn expr_tuple(&self, sp: Span, exprs: Vec<P<ast::Expr>>) -> P<ast::Expr> {
self.expr(sp, ast::ExprTup(exprs))
}
Expand Down

0 comments on commit b003f10

Please sign in to comment.