@@ -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,7 +788,7 @@ impl<'a> ReplaceBodyWithLoop<'a> {
788788 }
789789}
790790
791- impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a > {
791+ impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a , ' _ > {
792792 fn visit_item_kind ( & mut self , i : & mut ast:: ItemKind ) {
793793 let is_const = match i {
794794 ast:: ItemKind :: Static ( ..) | ast:: ItemKind :: Const ( ..) => true ,
@@ -826,40 +826,40 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
826826 fn visit_block ( & mut self , b : & mut P < ast:: Block > ) {
827827 fn stmt_to_block ( rules : ast:: BlockCheckMode ,
828828 s : Option < ast:: Stmt > ,
829- sess : & Session ) -> ast:: Block {
829+ resolver : & mut Resolver < ' _ > ) -> ast:: Block {
830830 ast:: Block {
831831 stmts : s. into_iter ( ) . collect ( ) ,
832832 rules,
833- id : sess . next_node_id ( ) ,
833+ id : resolver . next_node_id ( ) ,
834834 span : syntax_pos:: DUMMY_SP ,
835835 }
836836 }
837837
838- fn block_to_stmt ( b : ast:: Block , sess : & Session ) -> ast:: Stmt {
838+ fn block_to_stmt ( b : ast:: Block , resolver : & mut Resolver < ' _ > ) -> ast:: Stmt {
839839 let expr = P ( ast:: Expr {
840- id : sess . next_node_id ( ) ,
840+ id : resolver . next_node_id ( ) ,
841841 kind : ast:: ExprKind :: Block ( P ( b) , None ) ,
842842 span : syntax_pos:: DUMMY_SP ,
843843 attrs : ThinVec :: new ( ) ,
844844 } ) ;
845845
846846 ast:: Stmt {
847- id : sess . next_node_id ( ) ,
847+ id : resolver . next_node_id ( ) ,
848848 kind : ast:: StmtKind :: Expr ( expr) ,
849849 span : syntax_pos:: DUMMY_SP ,
850850 }
851851 }
852852
853- let empty_block = stmt_to_block ( BlockCheckMode :: Default , None , self . sess ) ;
853+ let empty_block = stmt_to_block ( BlockCheckMode :: Default , None , self . resolver ) ;
854854 let loop_expr = P ( ast:: Expr {
855855 kind : ast:: ExprKind :: Loop ( P ( empty_block) , None ) ,
856- id : self . sess . next_node_id ( ) ,
856+ id : self . resolver . next_node_id ( ) ,
857857 span : syntax_pos:: DUMMY_SP ,
858858 attrs : ThinVec :: new ( ) ,
859859 } ) ;
860860
861861 let loop_stmt = ast:: Stmt {
862- id : self . sess . next_node_id ( ) ,
862+ id : self . resolver . next_node_id ( ) ,
863863 span : syntax_pos:: DUMMY_SP ,
864864 kind : ast:: StmtKind :: Expr ( loop_expr) ,
865865 } ;
@@ -877,7 +877,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
877877 // we put a Some in there earlier with that replace(), so this is valid
878878 let new_blocks = self . nested_blocks . take ( ) . unwrap ( ) ;
879879 self . nested_blocks = old_blocks;
880- stmts. extend ( new_blocks. into_iter ( ) . map ( |b| block_to_stmt ( b, & self . sess ) ) ) ;
880+ stmts. extend ( new_blocks. into_iter ( ) . map ( |b| block_to_stmt ( b, self . resolver ) ) ) ;
881881 }
882882
883883 let mut new_block = ast:: Block {
@@ -891,7 +891,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
891891 old_blocks. push ( new_block) ;
892892 }
893893
894- stmt_to_block ( b. rules , Some ( loop_stmt) , self . sess )
894+ stmt_to_block ( b. rules , Some ( loop_stmt) , & mut self . resolver )
895895 } else {
896896 //push `loop {}` onto the end of our fresh block and yield that
897897 new_block. stmts . push ( loop_stmt) ;
0 commit comments