@@ -18,7 +18,7 @@ use rustc_mir;
18
18
use rustc_passes;
19
19
use rustc_plugin;
20
20
use rustc_privacy;
21
- use rustc_resolve;
21
+ use rustc_resolve:: { self , Resolver } ;
22
22
use rustc_typeck;
23
23
use std:: env;
24
24
use std:: env:: consts:: { DLL_PREFIX , DLL_SUFFIX } ;
@@ -715,18 +715,18 @@ pub fn build_output_filenames(
715
715
// ambitious form of the closed RFC #1637. See also [#34511].
716
716
//
717
717
// [#34511]: https://github.com/rust-lang/rust/issues/34511#issuecomment-322340401
718
- pub struct ReplaceBodyWithLoop < ' a > {
718
+ pub struct ReplaceBodyWithLoop < ' a , ' b > {
719
719
within_static_or_const : bool ,
720
720
nested_blocks : Option < Vec < ast:: Block > > ,
721
- sess : & ' a Session ,
721
+ resolver : & ' a mut Resolver < ' b > ,
722
722
}
723
723
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 > {
726
726
ReplaceBodyWithLoop {
727
727
within_static_or_const : false ,
728
728
nested_blocks : None ,
729
- sess
729
+ resolver ,
730
730
}
731
731
}
732
732
@@ -788,7 +788,7 @@ impl<'a> ReplaceBodyWithLoop<'a> {
788
788
}
789
789
}
790
790
791
- impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a > {
791
+ impl < ' a > MutVisitor for ReplaceBodyWithLoop < ' a , ' _ > {
792
792
fn visit_item_kind ( & mut self , i : & mut ast:: ItemKind ) {
793
793
let is_const = match i {
794
794
ast:: ItemKind :: Static ( ..) | ast:: ItemKind :: Const ( ..) => true ,
@@ -826,40 +826,40 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
826
826
fn visit_block ( & mut self , b : & mut P < ast:: Block > ) {
827
827
fn stmt_to_block ( rules : ast:: BlockCheckMode ,
828
828
s : Option < ast:: Stmt > ,
829
- sess : & Session ) -> ast:: Block {
829
+ resolver : & mut Resolver < ' _ > ) -> ast:: Block {
830
830
ast:: Block {
831
831
stmts : s. into_iter ( ) . collect ( ) ,
832
832
rules,
833
- id : sess . next_node_id ( ) ,
833
+ id : resolver . next_node_id ( ) ,
834
834
span : syntax_pos:: DUMMY_SP ,
835
835
}
836
836
}
837
837
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 {
839
839
let expr = P ( ast:: Expr {
840
- id : sess . next_node_id ( ) ,
840
+ id : resolver . next_node_id ( ) ,
841
841
kind : ast:: ExprKind :: Block ( P ( b) , None ) ,
842
842
span : syntax_pos:: DUMMY_SP ,
843
843
attrs : ThinVec :: new ( ) ,
844
844
} ) ;
845
845
846
846
ast:: Stmt {
847
- id : sess . next_node_id ( ) ,
847
+ id : resolver . next_node_id ( ) ,
848
848
kind : ast:: StmtKind :: Expr ( expr) ,
849
849
span : syntax_pos:: DUMMY_SP ,
850
850
}
851
851
}
852
852
853
- let empty_block = stmt_to_block ( BlockCheckMode :: Default , None , self . sess ) ;
853
+ let empty_block = stmt_to_block ( BlockCheckMode :: Default , None , self . resolver ) ;
854
854
let loop_expr = P ( ast:: Expr {
855
855
kind : ast:: ExprKind :: Loop ( P ( empty_block) , None ) ,
856
- id : self . sess . next_node_id ( ) ,
856
+ id : self . resolver . next_node_id ( ) ,
857
857
span : syntax_pos:: DUMMY_SP ,
858
858
attrs : ThinVec :: new ( ) ,
859
859
} ) ;
860
860
861
861
let loop_stmt = ast:: Stmt {
862
- id : self . sess . next_node_id ( ) ,
862
+ id : self . resolver . next_node_id ( ) ,
863
863
span : syntax_pos:: DUMMY_SP ,
864
864
kind : ast:: StmtKind :: Expr ( loop_expr) ,
865
865
} ;
@@ -877,7 +877,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
877
877
// we put a Some in there earlier with that replace(), so this is valid
878
878
let new_blocks = self . nested_blocks . take ( ) . unwrap ( ) ;
879
879
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 ) ) ) ;
881
881
}
882
882
883
883
let mut new_block = ast:: Block {
@@ -891,7 +891,7 @@ impl<'a> MutVisitor for ReplaceBodyWithLoop<'a> {
891
891
old_blocks. push ( new_block) ;
892
892
}
893
893
894
- stmt_to_block ( b. rules , Some ( loop_stmt) , self . sess )
894
+ stmt_to_block ( b. rules , Some ( loop_stmt) , & mut self . resolver )
895
895
} else {
896
896
//push `loop {}` onto the end of our fresh block and yield that
897
897
new_block. stmts . push ( loop_stmt) ;
0 commit comments