File tree 1 file changed +22
-2
lines changed
compiler/rustc_hir_pretty/src
1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1095,8 +1095,8 @@ impl<'a> State<'a> {
1095
1095
1096
1096
fn print_else ( & mut self , els : Option < & hir:: Expr < ' _ > > ) {
1097
1097
match els {
1098
- Some ( _else ) => {
1099
- match _else . kind {
1098
+ Some ( else_ ) => {
1099
+ match else_ . kind {
1100
1100
// "another else-if"
1101
1101
hir:: ExprKind :: If ( ref i, ref then, ref e) => {
1102
1102
self . cbox ( INDENT_UNIT - 1 ) ;
@@ -1114,6 +1114,26 @@ impl<'a> State<'a> {
1114
1114
self . s . word ( " else " ) ;
1115
1115
self . print_block ( & b)
1116
1116
}
1117
+ hir:: ExprKind :: Match ( ref expr, arms, _) => {
1118
+ // else if let desugared to match
1119
+ assert ! ( arms. len( ) == 2 , "if let desugars to match with two arms" ) ;
1120
+
1121
+ self . s . word ( " else " ) ;
1122
+ self . s . word ( "{" ) ;
1123
+
1124
+ self . cbox ( INDENT_UNIT ) ;
1125
+ self . ibox ( INDENT_UNIT ) ;
1126
+ self . word_nbsp ( "match" ) ;
1127
+ self . print_expr_as_cond ( & expr) ;
1128
+ self . s . space ( ) ;
1129
+ self . bopen ( ) ;
1130
+ for arm in arms {
1131
+ self . print_arm ( arm) ;
1132
+ }
1133
+ self . bclose ( expr. span ) ;
1134
+
1135
+ self . s . word ( "}" ) ;
1136
+ }
1117
1137
// BLEAH, constraints would be great here
1118
1138
_ => {
1119
1139
panic ! ( "print_if saw if with weird alternative" ) ;
You can’t perform that action at this time.
0 commit comments