@@ -13,7 +13,7 @@ use std::{env, sync::Arc};
13
13
use base_db:: { fixture:: WithFixture , FileRange , SourceDatabase , SourceDatabaseExt } ;
14
14
use expect_test:: Expect ;
15
15
use hir_def:: {
16
- body:: { BodySourceMap , SyntheticSyntax } ,
16
+ body:: { Body , BodySourceMap , SyntheticSyntax } ,
17
17
child_by_source:: ChildBySource ,
18
18
db:: DefDatabase ,
19
19
item_scope:: ItemScope ,
@@ -234,13 +234,13 @@ fn visit_module(
234
234
let def = it. into ( ) ;
235
235
cb ( def) ;
236
236
let body = db. body ( def) ;
237
- visit_scope ( db, crate_def_map , & body. item_scope , cb) ;
237
+ visit_body ( db, & body, cb) ;
238
238
}
239
239
AssocItemId :: ConstId ( it) => {
240
240
let def = it. into ( ) ;
241
241
cb ( def) ;
242
242
let body = db. body ( def) ;
243
- visit_scope ( db, crate_def_map , & body. item_scope , cb) ;
243
+ visit_body ( db, & body, cb) ;
244
244
}
245
245
AssocItemId :: TypeAliasId ( _) => ( ) ,
246
246
}
@@ -259,19 +259,19 @@ fn visit_module(
259
259
let def = it. into ( ) ;
260
260
cb ( def) ;
261
261
let body = db. body ( def) ;
262
- visit_scope ( db, crate_def_map , & body. item_scope , cb) ;
262
+ visit_body ( db, & body, cb) ;
263
263
}
264
264
ModuleDefId :: ConstId ( it) => {
265
265
let def = it. into ( ) ;
266
266
cb ( def) ;
267
267
let body = db. body ( def) ;
268
- visit_scope ( db, crate_def_map , & body. item_scope , cb) ;
268
+ visit_body ( db, & body, cb) ;
269
269
}
270
270
ModuleDefId :: StaticId ( it) => {
271
271
let def = it. into ( ) ;
272
272
cb ( def) ;
273
273
let body = db. body ( def) ;
274
- visit_scope ( db, crate_def_map , & body. item_scope , cb) ;
274
+ visit_body ( db, & body, cb) ;
275
275
}
276
276
ModuleDefId :: TraitId ( it) => {
277
277
let trait_data = db. trait_data ( it) ;
@@ -288,6 +288,14 @@ fn visit_module(
288
288
}
289
289
}
290
290
}
291
+
292
+ fn visit_body ( db : & TestDB , body : & Body , cb : & mut dyn FnMut ( DefWithBodyId ) ) {
293
+ for def_map in body. block_scopes . iter ( ) . filter_map ( |block| db. block_def_map ( * block) ) {
294
+ for ( mod_id, _) in def_map. modules ( ) {
295
+ visit_module ( db, & def_map, mod_id, cb) ;
296
+ }
297
+ }
298
+ }
291
299
}
292
300
293
301
fn ellipsize ( mut text : String , max_len : usize ) -> String {
0 commit comments