@@ -21,7 +21,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
21
21
fn make_mirror < ' a > ( self , cx : & mut Cx < ' a , ' tcx > ) -> Block < ' tcx > {
22
22
// We have to eagerly translate the "spine" of the statements
23
23
// in order to get the lexical scoping correctly.
24
- let stmts = mirror_stmts ( cx, self . id , self . stmts . iter ( ) . enumerate ( ) ) ;
24
+ let stmts = mirror_stmts ( cx, self . id , & * self . stmts ) ;
25
25
Block {
26
26
extent : cx. tcx . region_maps . node_extent ( self . id ) ,
27
27
span : self . span ,
@@ -31,14 +31,13 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
31
31
}
32
32
}
33
33
34
- fn mirror_stmts < ' a , ' tcx : ' a , STMTS > ( cx : & mut Cx < ' a , ' tcx > ,
35
- block_id : ast:: NodeId ,
36
- mut stmts : STMTS )
37
- -> Vec < StmtRef < ' tcx > >
38
- where STMTS : Iterator < Item =( usize , & ' tcx hir:: Stmt ) >
34
+ fn mirror_stmts < ' a , ' tcx : ' a > ( cx : & mut Cx < ' a , ' tcx > ,
35
+ block_id : ast:: NodeId ,
36
+ stmts : & ' tcx [ hir:: Stmt ] )
37
+ -> Vec < StmtRef < ' tcx > >
39
38
{
40
39
let mut result = vec ! [ ] ;
41
- while let Some ( ( index, stmt) ) = stmts. next ( ) {
40
+ for ( index, stmt) in stmts. iter ( ) . enumerate ( ) {
42
41
match stmt. node {
43
42
hir:: StmtExpr ( ref expr, id) | hir:: StmtSemi ( ref expr, id) =>
44
43
result. push ( StmtRef :: Mirror ( Box :: new ( Stmt {
@@ -48,28 +47,26 @@ fn mirror_stmts<'a,'tcx:'a,STMTS>(cx: &mut Cx<'a,'tcx>,
48
47
expr : expr. to_ref ( )
49
48
}
50
49
} ) ) ) ,
51
- hir:: StmtDecl ( ref decl, id) => {
52
- match decl. node {
53
- hir:: DeclItem ( ..) => { /* ignore for purposes of the MIR */ }
54
- hir:: DeclLocal ( ref local) => {
55
- let remainder_extent = CodeExtentData :: Remainder ( BlockRemainder {
56
- block : block_id,
57
- first_statement_index : index as u32 ,
58
- } ) ;
59
- let remainder_extent =
60
- cx. tcx . region_maps . lookup_code_extent ( remainder_extent) ;
50
+ hir:: StmtDecl ( ref decl, id) => match decl. node {
51
+ hir:: DeclItem ( ..) => { /* ignore for purposes of the MIR */ }
52
+ hir:: DeclLocal ( ref local) => {
53
+ let remainder_extent = CodeExtentData :: Remainder ( BlockRemainder {
54
+ block : block_id,
55
+ first_statement_index : index as u32 ,
56
+ } ) ;
57
+ let remainder_extent =
58
+ cx. tcx . region_maps . lookup_code_extent ( remainder_extent) ;
61
59
62
- let pattern = cx. irrefutable_pat ( & local. pat ) ;
63
- result. push ( StmtRef :: Mirror ( Box :: new ( Stmt {
64
- span : stmt. span ,
65
- kind : StmtKind :: Let {
66
- remainder_scope : remainder_extent,
67
- init_scope : cx. tcx . region_maps . node_extent ( id) ,
68
- pattern : pattern,
69
- initializer : local. init . to_ref ( ) ,
70
- } ,
71
- } ) ) ) ;
72
- }
60
+ let pattern = cx. irrefutable_pat ( & local. pat ) ;
61
+ result. push ( StmtRef :: Mirror ( Box :: new ( Stmt {
62
+ span : stmt. span ,
63
+ kind : StmtKind :: Let {
64
+ remainder_scope : remainder_extent,
65
+ init_scope : cx. tcx . region_maps . node_extent ( id) ,
66
+ pattern : pattern,
67
+ initializer : local. init . to_ref ( ) ,
68
+ } ,
69
+ } ) ) ) ;
73
70
}
74
71
}
75
72
}
0 commit comments