1
1
use log:: info;
2
2
use rustc_ast:: ast:: { AttrVec , BlockCheckMode } ;
3
- use rustc_ast:: mut_visit:: { visit_clobber, MutVisitor , * } ;
3
+ use rustc_ast:: mut_visit:: { /* visit_clobber,*/ MutVisitor , * } ;
4
4
use rustc_ast:: ptr:: P ;
5
5
use rustc_ast:: util:: lev_distance:: find_best_match_for_name;
6
6
use rustc_ast:: { self , ast} ;
@@ -29,7 +29,7 @@ use smallvec::SmallVec;
29
29
use std:: env;
30
30
use std:: io:: { self , Write } ;
31
31
use std:: mem;
32
- use std:: ops:: DerefMut ;
32
+ // use std::ops::DerefMut;
33
33
use std:: path:: { Path , PathBuf } ;
34
34
use std:: sync:: { Arc , Mutex , Once } ;
35
35
#[ cfg( not( parallel_compiler) ) ]
@@ -593,7 +593,7 @@ pub fn build_output_filenames(
593
593
// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
594
594
pub struct ReplaceBodyWithLoop < ' a , ' b > {
595
595
within_static_or_const : bool ,
596
- nested_blocks : Option < Vec < ast:: Block > > ,
596
+ nested_blocks : Option < Vec < ast:: Stmt > > ,
597
597
resolver : & ' a mut Resolver < ' b > ,
598
598
}
599
599
@@ -707,6 +707,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
707
707
}
708
708
}
709
709
710
+ /*
710
711
fn block_to_stmt(b: ast::Block, resolver: &mut Resolver<'_>) -> ast::Stmt {
711
712
let expr = P(ast::Expr {
712
713
id: resolver.next_node_id(),
@@ -722,6 +723,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
722
723
span: rustc_span::DUMMY_SP,
723
724
}
724
725
}
726
+ */
725
727
726
728
let empty_block = stmt_to_block ( BlockCheckMode :: Default , None , self . resolver ) ;
727
729
let loop_expr = P ( ast:: Expr {
@@ -741,35 +743,37 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a, '_> {
741
743
if self . within_static_or_const {
742
744
noop_visit_block ( b, self )
743
745
} else {
744
- visit_clobber ( b. deref_mut ( ) , |b| {
746
+ // visit_clobber(b.deref_mut(), |b| {
745
747
let mut stmts = vec ! [ ] ;
746
- for s in b. stmts {
748
+ for s in b. stmts . drain ( .. ) {
747
749
let old_blocks = self . nested_blocks . replace ( vec ! [ ] ) ;
748
750
749
751
stmts. extend ( self . flat_map_stmt ( s) . into_iter ( ) . filter ( |s| s. is_item ( ) ) ) ;
750
752
751
753
// we put a Some in there earlier with that replace(), so this is valid
752
754
let new_blocks = self . nested_blocks . take ( ) . unwrap ( ) ;
753
755
self . nested_blocks = old_blocks;
754
- stmts. extend ( new_blocks. into_iter ( ) . map ( |b| block_to_stmt ( b, self . resolver ) ) ) ;
756
+ stmts. extend ( new_blocks) ; // .into_iter().map(|b| block_to_stmt(b, self.resolver)));
755
757
}
756
758
757
- let mut new_block = ast:: Block { stmts, ..b } ;
759
+ // let mut new_block = ast::Block { stmts, ..b };
758
760
759
761
if let Some ( old_blocks) = self . nested_blocks . as_mut ( ) {
760
762
//push our fresh block onto the cache and yield an empty block with `loop {}`
761
- if !new_block. stmts . is_empty ( ) {
762
- old_blocks. push ( new_block) ;
763
+ if !stmts. is_empty ( ) {
764
+ //old_blocks.push(new_block);
765
+ old_blocks. extend ( stmts) ;
763
766
}
764
767
765
- stmt_to_block ( b. rules , Some ( loop_stmt) , & mut self . resolver )
768
+ b. stmts = vec ! [ loop_stmt] ;
769
+ //stmt_to_block(b.rules, Some(loop_stmt), &mut self.resolver)
766
770
} else {
767
771
//push `loop {}` onto the end of our fresh block and yield that
768
- new_block . stmts . push ( loop_stmt) ;
772
+ stmts. push ( loop_stmt) ;
769
773
770
- new_block
774
+ b . stmts = stmts ;
771
775
}
772
- } )
776
+ // })
773
777
}
774
778
}
775
779
0 commit comments