@@ -30,7 +30,7 @@ use rustc::traits::Reveal;
30
30
use rustc:: ty:: { self , Ty , TyCtxt } ;
31
31
use rustc:: ty:: subst:: Substs ;
32
32
use rustc:: hir;
33
- use rustc:: hir:: intravisit:: { self , FnKind , Visitor } ;
33
+ use rustc:: hir:: intravisit:: { self , FnKind , Visitor , NestedVisitMode } ;
34
34
use syntax:: abi:: Abi ;
35
35
use syntax:: ast;
36
36
use syntax_pos:: Span ;
@@ -144,6 +144,10 @@ impl<'a, 'gcx> BuildMir<'a, 'gcx> {
144
144
}
145
145
146
146
impl < ' a , ' tcx > Visitor < ' tcx > for BuildMir < ' a , ' tcx > {
147
+ fn nested_visit_map ( & mut self ) -> Option < ( & hir:: map:: Map < ' tcx > , NestedVisitMode ) > {
148
+ Some ( ( & self . tcx . map , NestedVisitMode :: OnlyBodies ) )
149
+ }
150
+
147
151
// Const and static items.
148
152
fn visit_item ( & mut self , item : & ' tcx hir:: Item ) {
149
153
match item. node {
@@ -210,7 +214,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
210
214
fn visit_fn ( & mut self ,
211
215
fk : FnKind < ' tcx > ,
212
216
decl : & ' tcx hir:: FnDecl ,
213
- body : & ' tcx hir:: Expr ,
217
+ body_id : hir:: ExprId ,
214
218
span : Span ,
215
219
id : ast:: NodeId ) {
216
220
// fetch the fully liberated fn signature (that is, all bound
@@ -223,7 +227,7 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
223
227
} ;
224
228
225
229
let ( abi, implicit_argument) = if let FnKind :: Closure ( ..) = fk {
226
- ( Abi :: Rust , Some ( ( closure_self_ty ( self . tcx , id, body . id ) , None ) ) )
230
+ ( Abi :: Rust , Some ( ( closure_self_ty ( self . tcx , id, body_id . node_id ( ) ) , None ) ) )
227
231
} else {
228
232
let def_id = self . tcx . map . local_def_id ( id) ;
229
233
( self . tcx . item_type ( def_id) . fn_abi ( ) , None )
@@ -237,12 +241,14 @@ impl<'a, 'tcx> Visitor<'tcx> for BuildMir<'a, 'tcx> {
237
241
( fn_sig. inputs [ index] , Some ( & * arg. pat ) )
238
242
} ) ;
239
243
244
+ let body = self . tcx . map . expr ( body_id) ;
245
+
240
246
let arguments = implicit_argument. into_iter ( ) . chain ( explicit_arguments) ;
241
247
self . cx ( MirSource :: Fn ( id) ) . build ( |cx| {
242
248
build:: construct_fn ( cx, id, arguments, abi, fn_sig. output , body)
243
249
} ) ;
244
250
245
- intravisit:: walk_fn ( self , fk, decl, body , span, id) ;
251
+ intravisit:: walk_fn ( self , fk, decl, body_id , span, id) ;
246
252
}
247
253
}
248
254
0 commit comments