@@ -132,7 +132,7 @@ pub(crate) fn format_expr(
132
132
ast:: ExprKind :: Tup ( ref items) => {
133
133
rewrite_tuple ( context, items. iter ( ) , expr. span , shape, items. len ( ) == 1 )
134
134
}
135
- ast:: ExprKind :: Let ( .. ) => None ,
135
+ ast:: ExprKind :: Let ( ref pat , ref expr , _span ) => rewrite_let ( context , shape , pat , expr ) ,
136
136
ast:: ExprKind :: If ( ..)
137
137
| ast:: ExprKind :: ForLoop ( ..)
138
138
| ast:: ExprKind :: Loop ( ..)
@@ -1834,6 +1834,37 @@ fn rewrite_tuple_in_visual_indent_style<'a, T: 'a + IntoOverflowableItem<'a>>(
1834
1834
Some ( format ! ( "({list_str})" ) )
1835
1835
}
1836
1836
1837
+ fn rewrite_let (
1838
+ context : & RewriteContext < ' _ > ,
1839
+ shape : Shape ,
1840
+ pat : & ast:: Pat ,
1841
+ expr : & ast:: Expr ,
1842
+ ) -> Option < String > {
1843
+ let mut result = "let " . to_owned ( ) ;
1844
+
1845
+ // 4 = "let ".len()
1846
+ let pat_shape = shape. offset_left ( 4 ) ?;
1847
+ let pat_str = pat. rewrite ( context, pat_shape) ?;
1848
+ result. push_str ( & pat_str) ;
1849
+
1850
+ result. push_str ( " =" ) ;
1851
+
1852
+ let comments_lo = context
1853
+ . snippet_provider
1854
+ . span_after ( expr. span . with_lo ( pat. span . hi ( ) ) , "=" ) ;
1855
+ let comments_span = mk_sp ( comments_lo, expr. span . lo ( ) ) ;
1856
+ rewrite_assign_rhs_with_comments (
1857
+ context,
1858
+ result,
1859
+ expr,
1860
+ shape,
1861
+ & RhsAssignKind :: Expr ( & expr. kind , expr. span ) ,
1862
+ RhsTactics :: Default ,
1863
+ comments_span,
1864
+ true ,
1865
+ )
1866
+ }
1867
+
1837
1868
pub ( crate ) fn rewrite_tuple < ' a , T : ' a + IntoOverflowableItem < ' a > > (
1838
1869
context : & ' a RewriteContext < ' _ > ,
1839
1870
items : impl Iterator < Item = & ' a T > ,
0 commit comments