@@ -1709,6 +1709,16 @@ impl<'a> State<'a> {
1709
1709
self . ann . post ( self , AnnNode :: Block ( blk) )
1710
1710
}
1711
1711
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
+
1712
1722
fn print_else ( & mut self , els : Option < & ast:: Expr > ) -> io:: Result < ( ) > {
1713
1723
match els {
1714
1724
Some ( _else) => {
@@ -1723,19 +1733,6 @@ impl<'a> State<'a> {
1723
1733
self . print_block ( then) ?;
1724
1734
self . print_else ( e. as_ref ( ) . map ( |e| & * * e) )
1725
1735
}
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
- }
1739
1736
// "final else"
1740
1737
ast:: ExprKind :: Block ( ref b, _) => {
1741
1738
self . cbox ( INDENT_UNIT - 1 ) ?;
@@ -1756,20 +1753,10 @@ impl<'a> State<'a> {
1756
1753
pub fn print_if ( & mut self , test : & ast:: Expr , blk : & ast:: Block ,
1757
1754
elseopt : Option < & ast:: Expr > ) -> io:: Result < ( ) > {
1758
1755
self . head ( "if" ) ?;
1756
+
1759
1757
self . print_expr_as_cond ( test) ?;
1760
1758
self . s . space ( ) ?;
1761
- self . print_block ( blk) ?;
1762
- self . print_else ( elseopt)
1763
- }
1764
1759
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 ( ) ?;
1773
1760
self . print_block ( blk) ?;
1774
1761
self . print_else ( elseopt)
1775
1762
}
@@ -2053,12 +2040,12 @@ impl<'a> State<'a> {
2053
2040
self . word_space ( ":" ) ?;
2054
2041
self . print_type ( ty) ?;
2055
2042
}
2043
+ ast:: ExprKind :: Let ( ref pats, ref scrutinee) => {
2044
+ self . print_let ( pats, scrutinee) ?;
2045
+ }
2056
2046
ast:: ExprKind :: If ( ref test, ref blk, ref elseopt) => {
2057
2047
self . print_if ( test, blk, elseopt. as_ref ( ) . map ( |e| & * * e) ) ?;
2058
2048
}
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
- }
2062
2049
ast:: ExprKind :: While ( ref test, ref blk, opt_label) => {
2063
2050
if let Some ( label) = opt_label {
2064
2051
self . print_ident ( label. ident ) ?;
@@ -2069,19 +2056,6 @@ impl<'a> State<'a> {
2069
2056
self . s . space ( ) ?;
2070
2057
self . print_block_with_attrs ( blk, attrs) ?;
2071
2058
}
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
- }
2085
2059
ast:: ExprKind :: ForLoop ( ref pat, ref iter, ref blk, opt_label) => {
2086
2060
if let Some ( label) = opt_label {
2087
2061
self . print_ident ( label. ident ) ?;
0 commit comments