diff options
| author | John Gallagher <jgallagher@bignerdranch.com> | 2014-10-02 23:28:15 -0400 |
|---|---|---|
| committer | John Gallagher <jgallagher@bignerdranch.com> | 2014-10-10 20:30:32 -0400 |
| commit | b003f104490599c49d27842c9a25b158e7cccdcb (patch) | |
| tree | b56dcc00c13f8b4a73890d165f9a8e2b28e81360 /src/libsyntax | |
| parent | 0c2c8116a307e88f8327e0ea846d2c9c135193b7 (diff) | |
| download | rust-b003f104490599c49d27842c9a25b158e7cccdcb.tar.gz rust-b003f104490599c49d27842c9a25b158e7cccdcb.zip | |
Desugar `while let` into `loop { match { ... } }`
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 3 | ||||
| -rw-r--r-- | src/libsyntax/ext/build.rs | 8 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 675249b2591..4ed3ee01598 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -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)] diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 87983e1aea3..98ac6fe6a6c 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -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>; @@ -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)) } |
