@@ -18,7 +18,7 @@ use rustc_mir;
1818use rustc_passes;
1919use rustc_plugin;
2020use rustc_privacy;
21- use rustc_resolve;
21+ use rustc_resolve:: { self , Resolver } ;
2222use rustc_typeck;
2323use std:: env;
2424use std:: env:: consts:: { DLL_PREFIX , DLL_SUFFIX } ;
@@ -715,18 +715,18 @@ pub fn build_output_filenames(
715715// ambitious form of the closed RFC #1637. See also [#34511].
716716//
717717// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
718- pub struct ReplaceBodyWithLoop < ' a > {
718+ pub struct ReplaceBodyWithLoop < ' a , ' b > {
719719 within_static_or_const : bool ,
720720 nested_blocks : Option < Vec < ast:: Block > > ,
721- sess : & ' a Session ,
721+ resolver : & ' a mut Resolver < ' b > ,
722722}
723723
724- impl < ' a > ReplaceBodyWithLoop < ' a > {
725- pub fn new ( sess : & ' a Session ) -> ReplaceBodyWithLoop < ' a > {
724+ impl < ' a , ' b > ReplaceBodyWithLoop < ' a , ' b > {
725+ pub fn new ( resolver : & ' a mut Resolver < ' b > ) -> ReplaceBodyWithLoop < ' a , ' b > {
726726 ReplaceBodyWithLoop {
727727 within_static_or_const : false ,
728728 nested_blocks : None ,
729- sess
729+ resolver ,
730730 }
731731 }
732732
@@ -788,11 +788,12 @@ impl<'a> ReplaceBodyWithLoop<'a> {
788788 }
789789
790790 fn is_sig_const ( sig : & ast:: FnSig ) -> bool {
791- sig. header . constness . node == ast:: Constness :: Const || Self :: should_ignore_fn ( & sig. decl )
791+ sig. header . constness . node == ast:: Constness :: Const ||
792+ ReplaceBodyWithLoop :: should_ignore_fn ( & sig. decl )
792793 }
793794}
794795
795- impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a > {
796+ impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a , ' _ > {
796797 fn visit_item_kind ( & mut self , i : & mut ast:: ItemKind ) {
797798 let is_const = match i {
798799 ast:: ItemKind :: Static ( ..) | ast:: ItemKind :: Const ( ..) => true ,
@@ -827,40 +828,40 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
827828 fn visit_block ( & mut self , b : & mut P < ast:: Block > ) {
828829 fn stmt_to_block ( rules : ast:: BlockCheckMode ,
829830 s : Option < ast:: Stmt > ,
830- sess : & Session ) -> ast:: Block {
831+ resolver : & mut Resolver < ' _ > ) -> ast:: Block {
831832 ast:: Block {
832833 stmts : s. into_iter ( ) . collect ( ) ,
833834 rules,
834- id : sess . next_node_id ( ) ,
835+ id : resolver . next_node_id ( ) ,
835836 span : syntax_pos:: DUMMY_SP ,
836837 }
837838 }
838839
839- fn block_to_stmt ( b : ast:: Block , sess : & Session ) -> ast:: Stmt {
840+ fn block_to_stmt ( b : ast:: Block , resolver : & mut Resolver < ' _ > ) -> ast:: Stmt {
840841 let expr = P ( ast:: Expr {
841- id : sess . next_node_id ( ) ,
842+ id : resolver . next_node_id ( ) ,
842843 kind : ast:: ExprKind :: Block ( P ( b) , None ) ,
843844 span : syntax_pos:: DUMMY_SP ,
844845 attrs : ThinVec :: new ( ) ,
845846 } ) ;
846847
847848 ast:: Stmt {
848- id : sess . next_node_id ( ) ,
849+ id : resolver . next_node_id ( ) ,
849850 kind : ast:: StmtKind :: Expr ( expr) ,
850851 span : syntax_pos:: DUMMY_SP ,
851852 }
852853 }
853854
854- let empty_block = stmt_to_block ( BlockCheckMode :: Default , None , self . sess ) ;
855+ let empty_block = stmt_to_block ( BlockCheckMode :: Default , None , self . resolver ) ;
855856 let loop_expr = P ( ast:: Expr {
856857 kind : ast:: ExprKind :: Loop ( P ( empty_block) , None ) ,
857- id : self . sess . next_node_id ( ) ,
858+ id : self . resolver . next_node_id ( ) ,
858859 span : syntax_pos:: DUMMY_SP ,
859860 attrs : ThinVec :: new ( ) ,
860861 } ) ;
861862
862863 let loop_stmt = ast:: Stmt {
863- id : self . sess . next_node_id ( ) ,
864+ id : self . resolver . next_node_id ( ) ,
864865 span : syntax_pos:: DUMMY_SP ,
865866 kind : ast:: StmtKind :: Expr ( loop_expr) ,
866867 } ;
@@ -878,7 +879,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
878879 // we put a Some in there earlier with that replace(), so this is valid
879880 let new_blocks = self . nested_blocks . take ( ) . unwrap ( ) ;
880881 self . nested_blocks = old_blocks;
881- stmts. extend ( new_blocks. into_iter ( ) . map ( |b| block_to_stmt ( b, & self . sess ) ) ) ;
882+ stmts. extend ( new_blocks. into_iter ( ) . map ( |b| block_to_stmt ( b, self . resolver ) ) ) ;
882883 }
883884
884885 let mut new_block = ast:: Block {
@@ -892,7 +893,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
892893 old_blocks. push ( new_block) ;
893894 }
894895
895- stmt_to_block ( b. rules , Some ( loop_stmt) , self . sess )
896+ stmt_to_block ( b. rules , Some ( loop_stmt) , & mut self . resolver )
896897 } else {
897898 //push `loop {}` onto the end of our fresh block and yield that
898899 new_block. stmts . push ( loop_stmt) ;
0 commit comments