@@ -127,7 +127,7 @@ pub(crate) fn format_expr(
127
127
ast:: ExprKind :: Tup ( ref items) => {
128
128
rewrite_tuple ( context, items. iter ( ) , expr. span , shape, items. len ( ) == 1 )
129
129
}
130
- ast:: ExprKind :: Let ( .. ) => None ,
130
+ ast:: ExprKind :: Let ( ref pat , ref expr , _span ) => rewrite_let ( context , shape , pat , expr ) ,
131
131
ast:: ExprKind :: If ( ..)
132
132
| ast:: ExprKind :: ForLoop ( ..)
133
133
| ast:: ExprKind :: Loop ( ..)
@@ -1779,6 +1779,37 @@ fn rewrite_tuple_in_visual_indent_style<'a, T: 'a + IntoOverflowableItem<'a>>(
1779
1779
Some ( format ! ( "({})" , list_str) )
1780
1780
}
1781
1781
1782
+ fn rewrite_let (
1783
+ context : & RewriteContext < ' _ > ,
1784
+ shape : Shape ,
1785
+ pat : & ast:: Pat ,
1786
+ expr : & ast:: Expr ,
1787
+ ) -> Option < String > {
1788
+ let mut result = "let " . to_owned ( ) ;
1789
+
1790
+ // 4 = "let ".len()
1791
+ let pat_shape = shape. offset_left ( 4 ) ?;
1792
+ let pat_str = pat. rewrite ( context, pat_shape) ?;
1793
+ result. push_str ( & pat_str) ;
1794
+
1795
+ result. push_str ( " =" ) ;
1796
+
1797
+ let comments_lo = context
1798
+ . snippet_provider
1799
+ . span_after ( expr. span . with_lo ( pat. span . hi ( ) ) , "=" ) ;
1800
+ let comments_span = mk_sp ( comments_lo, expr. span . lo ( ) ) ;
1801
+ rewrite_assign_rhs_with_comments (
1802
+ context,
1803
+ result,
1804
+ expr,
1805
+ shape,
1806
+ & RhsAssignKind :: Expr ( & expr. kind , expr. span ) ,
1807
+ RhsTactics :: Default ,
1808
+ comments_span,
1809
+ true ,
1810
+ )
1811
+ }
1812
+
1782
1813
pub ( crate ) fn rewrite_tuple < ' a , T : ' a + IntoOverflowableItem < ' a > > (
1783
1814
context : & ' a RewriteContext < ' _ > ,
1784
1815
items : impl Iterator < Item = & ' a T > ,
0 commit comments