@@ -275,6 +275,8 @@ struct DefCollector<'a> {
275
275
276
276
impl DefCollector < ' _ > {
277
277
fn seed_with_top_level ( & mut self ) {
278
+ let _p = profile:: span ( "seed_with_top_level" ) ;
279
+
278
280
let file_id = self . db . crate_graph ( ) [ self . def_map . krate ] . root_file_id ;
279
281
let item_tree = self . db . file_item_tree ( file_id. into ( ) ) ;
280
282
let module_id = self . def_map . root ;
@@ -346,15 +348,20 @@ impl DefCollector<'_> {
346
348
}
347
349
}
348
350
349
- fn collect ( & mut self ) {
351
+ fn resolution_loop ( & mut self ) {
352
+ let _p = profile:: span ( "DefCollector::resolution_loop" ) ;
353
+
350
354
// main name resolution fixed-point loop.
351
355
let mut i = 0 ;
352
356
' outer: loop {
353
357
loop {
354
358
self . db . unwind_if_cancelled ( ) ;
355
- loop {
356
- if self . resolve_imports ( ) == ReachedFixedPoint :: Yes {
357
- break ;
359
+ {
360
+ let _p = profile:: span ( "resolve_imports loop" ) ;
361
+ loop {
362
+ if self . resolve_imports ( ) == ReachedFixedPoint :: Yes {
363
+ break ;
364
+ }
358
365
}
359
366
}
360
367
if self . resolve_macros ( ) == ReachedFixedPoint :: Yes {
@@ -372,6 +379,12 @@ impl DefCollector<'_> {
372
379
break ;
373
380
}
374
381
}
382
+ }
383
+
384
+ fn collect ( & mut self ) {
385
+ let _p = profile:: span ( "DefCollector::collect" ) ;
386
+
387
+ self . resolution_loop ( ) ;
375
388
376
389
// Resolve all indeterminate resolved imports again
377
390
// As some of the macros will expand newly import shadowing partial resolved imports
@@ -723,6 +736,7 @@ impl DefCollector<'_> {
723
736
}
724
737
725
738
fn resolve_import ( & self , module_id : LocalModuleId , import : & Import ) -> PartialResolvedImport {
739
+ let _p = profile:: span ( "resolve_import" ) . detail ( || format ! ( "{}" , import. path) ) ;
726
740
tracing:: debug!( "resolving import: {:?} ({:?})" , import, self . def_map. edition) ;
727
741
if import. is_extern_crate {
728
742
let name = import
@@ -790,6 +804,8 @@ impl DefCollector<'_> {
790
804
}
791
805
792
806
fn record_resolved_import ( & mut self , directive : & ImportDirective ) {
807
+ let _p = profile:: span ( "record_resolved_import" ) ;
808
+
793
809
let module_id = directive. module_id ;
794
810
let import = & directive. import ;
795
811
let mut def = directive. status . namespaces ( ) ;
@@ -1244,6 +1260,8 @@ impl DefCollector<'_> {
1244
1260
fn finish ( mut self ) -> DefMap {
1245
1261
// Emit diagnostics for all remaining unexpanded macros.
1246
1262
1263
+ let _p = profile:: span ( "DefCollector::finish" ) ;
1264
+
1247
1265
for directive in & self . unresolved_macros {
1248
1266
match & directive. kind {
1249
1267
MacroDirectiveKind :: FnLike { ast_id, expand_to } => {
0 commit comments