@@ -1709,6 +1709,16 @@ impl<'a> State<'a> {
17091709 self . ann . post ( self , AnnNode :: Block ( blk) )
17101710 }
17111711
1712+ pub fn print_let ( & mut self , pats : & [ P < ast:: Pat > ] , scrutinee : & ast:: Expr ) -> io:: Result < ( ) > {
1713+ self . s . word ( "let " ) ?;
1714+
1715+ self . print_pats ( pats) ?;
1716+ self . s . space ( ) ?;
1717+
1718+ self . word_space ( "=" ) ?;
1719+ self . print_expr_as_cond ( scrutinee)
1720+ }
1721+
17121722 fn print_else ( & mut self , els : Option < & ast:: Expr > ) -> io:: Result < ( ) > {
17131723 match els {
17141724 Some ( _else) => {
@@ -1723,19 +1733,6 @@ impl<'a> State<'a> {
17231733 self . print_block ( then) ?;
17241734 self . print_else ( e. as_ref ( ) . map ( |e| & * * e) )
17251735 }
1726- // "another else-if-let"
1727- ast:: ExprKind :: IfLet ( ref pats, ref expr, ref then, ref e) => {
1728- self . cbox ( INDENT_UNIT - 1 ) ?;
1729- self . ibox ( 0 ) ?;
1730- self . s . word ( " else if let " ) ?;
1731- self . print_pats ( pats) ?;
1732- self . s . space ( ) ?;
1733- self . word_space ( "=" ) ?;
1734- self . print_expr_as_cond ( expr) ?;
1735- self . s . space ( ) ?;
1736- self . print_block ( then) ?;
1737- self . print_else ( e. as_ref ( ) . map ( |e| & * * e) )
1738- }
17391736 // "final else"
17401737 ast:: ExprKind :: Block ( ref b, _) => {
17411738 self . cbox ( INDENT_UNIT - 1 ) ?;
@@ -1756,20 +1753,10 @@ impl<'a> State<'a> {
17561753 pub fn print_if ( & mut self , test : & ast:: Expr , blk : & ast:: Block ,
17571754 elseopt : Option < & ast:: Expr > ) -> io:: Result < ( ) > {
17581755 self . head ( "if" ) ?;
1756+
17591757 self . print_expr_as_cond ( test) ?;
17601758 self . s . space ( ) ?;
1761- self . print_block ( blk) ?;
1762- self . print_else ( elseopt)
1763- }
17641759
1765- pub fn print_if_let ( & mut self , pats : & [ P < ast:: Pat > ] , expr : & ast:: Expr , blk : & ast:: Block ,
1766- elseopt : Option < & ast:: Expr > ) -> io:: Result < ( ) > {
1767- self . head ( "if let" ) ?;
1768- self . print_pats ( pats) ?;
1769- self . s . space ( ) ?;
1770- self . word_space ( "=" ) ?;
1771- self . print_expr_as_cond ( expr) ?;
1772- self . s . space ( ) ?;
17731760 self . print_block ( blk) ?;
17741761 self . print_else ( elseopt)
17751762 }
@@ -2053,12 +2040,12 @@ impl<'a> State<'a> {
20532040 self . word_space ( ":" ) ?;
20542041 self . print_type ( ty) ?;
20552042 }
2043+ ast:: ExprKind :: Let ( ref pats, ref scrutinee) => {
2044+ self . print_let ( pats, scrutinee) ?;
2045+ }
20562046 ast:: ExprKind :: If ( ref test, ref blk, ref elseopt) => {
20572047 self . print_if ( test, blk, elseopt. as_ref ( ) . map ( |e| & * * e) ) ?;
20582048 }
2059- ast:: ExprKind :: IfLet ( ref pats, ref expr, ref blk, ref elseopt) => {
2060- self . print_if_let ( pats, expr, blk, elseopt. as_ref ( ) . map ( |e| & * * e) ) ?;
2061- }
20622049 ast:: ExprKind :: While ( ref test, ref blk, opt_label) => {
20632050 if let Some ( label) = opt_label {
20642051 self . print_ident ( label. ident ) ?;
@@ -2069,19 +2056,6 @@ impl<'a> State<'a> {
20692056 self . s . space ( ) ?;
20702057 self . print_block_with_attrs ( blk, attrs) ?;
20712058 }
2072- ast:: ExprKind :: WhileLet ( ref pats, ref expr, ref blk, opt_label) => {
2073- if let Some ( label) = opt_label {
2074- self . print_ident ( label. ident ) ?;
2075- self . word_space ( ":" ) ?;
2076- }
2077- self . head ( "while let" ) ?;
2078- self . print_pats ( pats) ?;
2079- self . s . space ( ) ?;
2080- self . word_space ( "=" ) ?;
2081- self . print_expr_as_cond ( expr) ?;
2082- self . s . space ( ) ?;
2083- self . print_block_with_attrs ( blk, attrs) ?;
2084- }
20852059 ast:: ExprKind :: ForLoop ( ref pat, ref iter, ref blk, opt_label) => {
20862060 if let Some ( label) = opt_label {
20872061 self . print_ident ( label. ident ) ?;
0 commit comments