@@ -21,7 +21,7 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
2121 fn make_mirror < ' a > ( self , cx : & mut Cx < ' a , ' tcx > ) -> Block < ' tcx > {
2222 // We have to eagerly translate the "spine" of the statements
2323 // 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 ) ;
2525 Block {
2626 extent : cx. tcx . region_maps . node_extent ( self . id ) ,
2727 span : self . span ,
@@ -31,14 +31,13 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Block {
3131 }
3232}
3333
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 > >
3938{
4039 let mut result = vec ! [ ] ;
41- while let Some ( ( index, stmt) ) = stmts. next ( ) {
40+ for ( index, stmt) in stmts. iter ( ) . enumerate ( ) {
4241 match stmt. node {
4342 hir:: StmtExpr ( ref expr, id) | hir:: StmtSemi ( ref expr, id) =>
4443 result. push ( StmtRef :: Mirror ( Box :: new ( Stmt {
@@ -48,28 +47,26 @@ fn mirror_stmts<'a,'tcx:'a,STMTS>(cx: &mut Cx<'a,'tcx>,
4847 expr : expr. to_ref ( )
4948 }
5049 } ) ) ) ,
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) ;
6159
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+ } ) ) ) ;
7370 }
7471 }
7572 }
0 commit comments