@@ -1183,11 +1183,13 @@ impl<'interner, 'def_map, 'string> Printer<'interner, 'def_map, 'string> {
1183
1183
self . push_str ( & field_element. to_string ( ) ) ;
1184
1184
}
1185
1185
Type :: InfixExpr ( lhs, op, rhs, _) => {
1186
+ self . push ( '(' ) ;
1186
1187
self . show_type ( lhs) ;
1187
1188
self . push ( ' ' ) ;
1188
1189
self . push_str ( & op. to_string ( ) ) ;
1189
1190
self . push ( ' ' ) ;
1190
1191
self . show_type ( rhs) ;
1192
+ self . push ( ')' ) ;
1191
1193
}
1192
1194
Type :: Unit
1193
1195
| Type :: Bool
@@ -1236,35 +1238,40 @@ impl<'interner, 'def_map, 'string> Printer<'interner, 'def_map, 'string> {
1236
1238
HirExpression :: Block ( hir_block_expression) => {
1237
1239
self . show_hir_block_expression ( hir_block_expression) ;
1238
1240
}
1239
- HirExpression :: Prefix ( hir_prefix_expression) => {
1240
- match hir_prefix_expression. operator {
1241
- UnaryOp :: Minus => {
1242
- self . push ( '-' ) ;
1243
- }
1244
- UnaryOp :: Not => {
1245
- self . push ( '!' ) ;
1246
- }
1247
- UnaryOp :: Reference { mutable } => {
1248
- if mutable {
1249
- self . push_str ( "&mut " ) ;
1250
- } else {
1251
- self . push_str ( "&" ) ;
1252
- }
1241
+ HirExpression :: Prefix ( hir_prefix_expression) => match hir_prefix_expression. operator {
1242
+ UnaryOp :: Minus => {
1243
+ self . push_str ( "-(" ) ;
1244
+ self . show_hir_expression_id ( hir_prefix_expression. rhs ) ;
1245
+ self . push ( ')' ) ;
1246
+ }
1247
+ UnaryOp :: Not => {
1248
+ self . push_str ( "!(" ) ;
1249
+ self . show_hir_expression_id ( hir_prefix_expression. rhs ) ;
1250
+ self . push ( ')' ) ;
1251
+ }
1252
+ UnaryOp :: Reference { mutable } => {
1253
+ if mutable {
1254
+ self . push_str ( "&mut " ) ;
1255
+ } else {
1256
+ self . push_str ( "&" ) ;
1253
1257
}
1254
- UnaryOp :: Dereference { implicitly_added } => {
1255
- if !implicitly_added {
1256
- self . push ( '*' ) ;
1257
- }
1258
+ self . show_hir_expression_id ( hir_prefix_expression. rhs ) ;
1259
+ }
1260
+ UnaryOp :: Dereference { implicitly_added } => {
1261
+ if !implicitly_added {
1262
+ self . push ( '*' ) ;
1258
1263
}
1264
+ self . show_hir_expression_id ( hir_prefix_expression. rhs ) ;
1259
1265
}
1260
- self . show_hir_expression_id ( hir_prefix_expression. rhs ) ;
1261
- }
1266
+ } ,
1262
1267
HirExpression :: Infix ( hir_infix_expression) => {
1268
+ self . push ( '(' ) ;
1263
1269
self . show_hir_expression_id ( hir_infix_expression. lhs ) ;
1264
1270
self . push ( ' ' ) ;
1265
1271
self . push_str ( & hir_infix_expression. operator . kind . to_string ( ) ) ;
1266
1272
self . push ( ' ' ) ;
1267
1273
self . show_hir_expression_id ( hir_infix_expression. rhs ) ;
1274
+ self . push ( ')' ) ;
1268
1275
}
1269
1276
HirExpression :: Index ( hir_index_expression) => {
1270
1277
self . show_hir_expression_id ( hir_index_expression. collection ) ;
0 commit comments