@@ -250,14 +250,14 @@ impl LoweringContext<'_> {
250
250
// 4. The return type of the block is `bool` which seems like what the user wanted.
251
251
let scrutinee = self . lower_expr ( scrutinee) ;
252
252
let then_arm = {
253
- let pat = self . lower_pat_top_hack ( pat) ;
253
+ let pat = self . lower_pat ( pat) ;
254
254
let expr = self . expr_bool ( span, true ) ;
255
255
self . arm ( pat, P ( expr) )
256
256
} ;
257
257
let else_arm = {
258
258
let pat = self . pat_wild ( span) ;
259
259
let expr = self . expr_bool ( span, false ) ;
260
- self . arm ( hir_vec ! [ pat] , P ( expr) )
260
+ self . arm ( pat, P ( expr) )
261
261
} ;
262
262
hir:: ExprKind :: Match (
263
263
P ( scrutinee) ,
@@ -281,7 +281,7 @@ impl LoweringContext<'_> {
281
281
None => ( self . expr_block_empty ( span) , false ) ,
282
282
Some ( els) => ( self . lower_expr ( els) , true ) ,
283
283
} ;
284
- let else_arm = self . arm ( hir_vec ! [ else_pat] , P ( else_expr) ) ;
284
+ let else_arm = self . arm ( else_pat, P ( else_expr) ) ;
285
285
286
286
// Handle then + scrutinee:
287
287
let then_blk = self . lower_block ( then, false ) ;
@@ -290,7 +290,7 @@ impl LoweringContext<'_> {
290
290
// `<pat> => <then>`:
291
291
ExprKind :: Let ( ref pat, ref scrutinee) => {
292
292
let scrutinee = self . lower_expr ( scrutinee) ;
293
- let pat = self . lower_pat_top_hack ( pat) ;
293
+ let pat = self . lower_pat ( pat) ;
294
294
( pat, scrutinee, hir:: MatchSource :: IfLetDesugar { contains_else_clause } )
295
295
}
296
296
// `true => <then>`:
@@ -307,7 +307,7 @@ impl LoweringContext<'_> {
307
307
// let temporaries live outside of `cond`.
308
308
let cond = self . expr_drop_temps ( span_block, P ( cond) , ThinVec :: new ( ) ) ;
309
309
let pat = self . pat_bool ( span, true ) ;
310
- ( hir_vec ! [ pat] , cond, hir:: MatchSource :: IfDesugar { contains_else_clause } )
310
+ ( pat, cond, hir:: MatchSource :: IfDesugar { contains_else_clause } )
311
311
}
312
312
} ;
313
313
let then_arm = self . arm ( then_pat, P ( then_expr) ) ;
@@ -331,7 +331,7 @@ impl LoweringContext<'_> {
331
331
let else_arm = {
332
332
let else_pat = self . pat_wild ( span) ;
333
333
let else_expr = self . expr_break ( span, ThinVec :: new ( ) ) ;
334
- self . arm ( hir_vec ! [ else_pat] , else_expr)
334
+ self . arm ( else_pat, else_expr)
335
335
} ;
336
336
337
337
// Handle then + scrutinee:
@@ -348,7 +348,7 @@ impl LoweringContext<'_> {
348
348
// }
349
349
// }
350
350
let scrutinee = self . with_loop_condition_scope ( |t| t. lower_expr ( scrutinee) ) ;
351
- let pat = self . lower_pat_top_hack ( pat) ;
351
+ let pat = self . lower_pat ( pat) ;
352
352
( pat, scrutinee, hir:: MatchSource :: WhileLetDesugar , hir:: LoopSource :: WhileLet )
353
353
}
354
354
_ => {
@@ -376,7 +376,7 @@ impl LoweringContext<'_> {
376
376
let cond = self . expr_drop_temps ( span_block, P ( cond) , ThinVec :: new ( ) ) ;
377
377
// `true => <then>`:
378
378
let pat = self . pat_bool ( span, true ) ;
379
- ( hir_vec ! [ pat] , cond, hir:: MatchSource :: WhileDesugar , hir:: LoopSource :: While )
379
+ ( pat, cond, hir:: MatchSource :: WhileDesugar , hir:: LoopSource :: While )
380
380
}
381
381
} ;
382
382
let then_arm = self . arm ( then_pat, P ( then_expr) ) ;
@@ -429,7 +429,7 @@ impl LoweringContext<'_> {
429
429
hir:: Arm {
430
430
hir_id : self . next_id ( ) ,
431
431
attrs : self . lower_attrs ( & arm. attrs ) ,
432
- pats : self . lower_pat_top_hack ( & arm. pat ) ,
432
+ pat : self . lower_pat ( & arm. pat ) ,
433
433
guard : match arm. guard {
434
434
Some ( ref x) => Some ( hir:: Guard :: If ( P ( self . lower_expr ( x) ) ) ) ,
435
435
_ => None ,
@@ -439,16 +439,6 @@ impl LoweringContext<'_> {
439
439
}
440
440
}
441
441
442
- /// HACK(or_patterns; Centril | dlrobertson): For now we don't push down top level or-patterns
443
- /// `p | q` into `hir::PatKind::Or(...)` as post-lowering bits of the compiler are not ready
444
- /// to deal with it. This should by fixed by pushing it down to HIR and then HAIR.
445
- fn lower_pat_top_hack ( & mut self , pat : & Pat ) -> HirVec < P < hir:: Pat > > {
446
- match pat. node {
447
- PatKind :: Or ( ref ps) => ps. iter ( ) . map ( |x| self . lower_pat ( x) ) . collect ( ) ,
448
- _ => hir_vec ! [ self . lower_pat( pat) ] ,
449
- }
450
- }
451
-
452
442
pub ( super ) fn make_async_expr (
453
443
& mut self ,
454
444
capture_clause : CaptureBy ,
@@ -597,7 +587,7 @@ impl LoweringContext<'_> {
597
587
) ;
598
588
P ( this. expr ( await_span, expr_break, ThinVec :: new ( ) ) )
599
589
} ) ;
600
- self . arm ( hir_vec ! [ ready_pat] , break_x)
590
+ self . arm ( ready_pat, break_x)
601
591
} ;
602
592
603
593
// `::std::task::Poll::Pending => {}`
@@ -608,7 +598,7 @@ impl LoweringContext<'_> {
608
598
hir_vec ! [ ] ,
609
599
) ;
610
600
let empty_block = P ( self . expr_block_empty ( span) ) ;
611
- self . arm ( hir_vec ! [ pending_pat] , empty_block)
601
+ self . arm ( pending_pat, empty_block)
612
602
} ;
613
603
614
604
let inner_match_stmt = {
@@ -650,7 +640,7 @@ impl LoweringContext<'_> {
650
640
} ) ;
651
641
652
642
// mut pinned => loop { ... }
653
- let pinned_arm = self . arm ( hir_vec ! [ pinned_pat] , loop_expr) ;
643
+ let pinned_arm = self . arm ( pinned_pat, loop_expr) ;
654
644
655
645
// match <expr> {
656
646
// mut pinned => loop { .. }
@@ -1084,15 +1074,15 @@ impl LoweringContext<'_> {
1084
1074
ThinVec :: new ( ) ,
1085
1075
) ) ;
1086
1076
let some_pat = self . pat_some ( pat. span , val_pat) ;
1087
- self . arm ( hir_vec ! [ some_pat] , assign)
1077
+ self . arm ( some_pat, assign)
1088
1078
} ;
1089
1079
1090
1080
// `::std::option::Option::None => break`
1091
1081
let break_arm = {
1092
1082
let break_expr =
1093
1083
self . with_loop_scope ( e. id , |this| this. expr_break ( e. span , ThinVec :: new ( ) ) ) ;
1094
1084
let pat = self . pat_none ( e. span ) ;
1095
- self . arm ( hir_vec ! [ pat] , break_expr)
1085
+ self . arm ( pat, break_expr)
1096
1086
} ;
1097
1087
1098
1088
// `mut iter`
@@ -1163,7 +1153,7 @@ impl LoweringContext<'_> {
1163
1153
} ) ;
1164
1154
1165
1155
// `mut iter => { ... }`
1166
- let iter_arm = self . arm ( hir_vec ! [ iter_pat] , loop_expr) ;
1156
+ let iter_arm = self . arm ( iter_pat, loop_expr) ;
1167
1157
1168
1158
// `match ::std::iter::IntoIterator::into_iter(<head>) { ... }`
1169
1159
let into_iter_expr = {
@@ -1249,7 +1239,7 @@ impl LoweringContext<'_> {
1249
1239
ThinVec :: from ( attrs. clone ( ) ) ,
1250
1240
) ) ;
1251
1241
let ok_pat = self . pat_ok ( span, val_pat) ;
1252
- self . arm ( hir_vec ! [ ok_pat] , val_expr)
1242
+ self . arm ( ok_pat, val_expr)
1253
1243
} ;
1254
1244
1255
1245
// `Err(err) => #[allow(unreachable_code)]
@@ -1284,7 +1274,7 @@ impl LoweringContext<'_> {
1284
1274
} ;
1285
1275
1286
1276
let err_pat = self . pat_err ( try_span, err_local) ;
1287
- self . arm ( hir_vec ! [ err_pat] , ret_expr)
1277
+ self . arm ( err_pat, ret_expr)
1288
1278
} ;
1289
1279
1290
1280
hir:: ExprKind :: Match (
@@ -1479,14 +1469,11 @@ impl LoweringContext<'_> {
1479
1469
}
1480
1470
}
1481
1471
1482
- /// HACK(or_patterns; Centril | dlrobertson): For now we don't push down top level or-patterns
1483
- /// `p | q` into `hir::PatKind::Or(...)` as post-lowering bits of the compiler are not ready
1484
- /// to deal with it. This should by fixed by pushing it down to HIR and then HAIR.
1485
- fn arm ( & mut self , pats : HirVec < P < hir:: Pat > > , expr : P < hir:: Expr > ) -> hir:: Arm {
1472
+ fn arm ( & mut self , pat : P < hir:: Pat > , expr : P < hir:: Expr > ) -> hir:: Arm {
1486
1473
hir:: Arm {
1487
1474
hir_id : self . next_id ( ) ,
1488
1475
attrs : hir_vec ! [ ] ,
1489
- pats ,
1476
+ pat ,
1490
1477
guard : None ,
1491
1478
span : expr. span ,
1492
1479
body : expr,
0 commit comments