@@ -29,7 +29,6 @@ use profile::{Bytes, StopWatch};
29
29
use project_model:: { CargoConfig , ProjectManifest , ProjectWorkspace , RustLibSource } ;
30
30
use rayon:: prelude:: * ;
31
31
use rustc_hash:: FxHashSet ;
32
- use stdx:: format_to;
33
32
use syntax:: { AstNode , SyntaxNode } ;
34
33
use vfs:: { AbsPathBuf , Vfs , VfsPath } ;
35
34
@@ -241,8 +240,10 @@ impl flags::AnalysisStats {
241
240
continue ;
242
241
}
243
242
all += 1 ;
244
- let Err ( e) = db. layout_of_adt ( hir_def:: AdtId :: from ( a) . into ( ) , Substitution :: empty ( Interner ) , a. krate ( db) . into ( ) ) else {
245
- continue ;
243
+ let Err ( e)
244
+ = db. layout_of_adt ( hir_def:: AdtId :: from ( a) . into ( ) , Substitution :: empty ( Interner ) , a. krate ( db) . into ( ) )
245
+ else {
246
+ continue
246
247
} ;
247
248
if verbosity. is_spammy ( ) {
248
249
let full_name = a
@@ -363,7 +364,7 @@ impl flags::AnalysisStats {
363
364
for & body_id in bodies {
364
365
let name = body_id. name ( db) . unwrap_or_else ( Name :: missing) ;
365
366
let module = body_id. module ( db) ;
366
- let full_name = || {
367
+ let full_name = move || {
367
368
module
368
369
. krate ( )
369
370
. display_name ( db)
@@ -375,7 +376,7 @@ impl flags::AnalysisStats {
375
376
. into_iter ( )
376
377
. filter_map ( |it| it. name ( db) )
377
378
. rev ( )
378
- . chain ( Some ( name. clone ( ) ) )
379
+ . chain ( Some ( body_id . name ( db ) . unwrap_or_else ( Name :: missing ) ) )
379
380
. map ( |it| it. display ( db) . to_string ( ) ) ,
380
381
)
381
382
. join ( "::" )
@@ -385,26 +386,31 @@ impl flags::AnalysisStats {
385
386
continue ;
386
387
}
387
388
}
388
- let mut msg = format ! ( "processing: {}" , full_name( ) ) ;
389
- if verbosity. is_verbose ( ) {
390
- let source = match body_id {
391
- DefWithBody :: Function ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
392
- DefWithBody :: Static ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
393
- DefWithBody :: Const ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
394
- DefWithBody :: Variant ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
395
- DefWithBody :: InTypeConst ( _) => unimplemented ! ( ) ,
396
- } ;
397
- if let Some ( src) = source {
398
- let original_file = src. file_id . original_file ( db) ;
399
- let path = vfs. file_path ( original_file) ;
400
- let syntax_range = src. value . text_range ( ) ;
401
- format_to ! ( msg, " ({} {:?})" , path, syntax_range) ;
389
+ let msg = move || {
390
+ if verbosity. is_verbose ( ) {
391
+ let source = match body_id {
392
+ DefWithBody :: Function ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
393
+ DefWithBody :: Static ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
394
+ DefWithBody :: Const ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
395
+ DefWithBody :: Variant ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
396
+ DefWithBody :: InTypeConst ( _) => unimplemented ! ( ) ,
397
+ } ;
398
+ if let Some ( src) = source {
399
+ let original_file = src. file_id . original_file ( db) ;
400
+ let path = vfs. file_path ( original_file) ;
401
+ let syntax_range = src. value . text_range ( ) ;
402
+ format ! ( "processing: {} ({} {:?})" , full_name( ) , path, syntax_range)
403
+ } else {
404
+ format ! ( "processing: {}" , full_name( ) )
405
+ }
406
+ } else {
407
+ format ! ( "processing: {}" , full_name( ) )
402
408
}
403
- }
409
+ } ;
404
410
if verbosity. is_spammy ( ) {
405
- bar. println ( msg. to_string ( ) ) ;
411
+ bar. println ( msg ( ) ) ;
406
412
}
407
- bar. set_message ( & msg) ;
413
+ bar. set_message ( msg) ;
408
414
let ( body, sm) = db. body_with_source_map ( body_id. into ( ) ) ;
409
415
let inference_result = db. infer ( body_id. into ( ) ) ;
410
416
@@ -641,16 +647,15 @@ impl flags::AnalysisStats {
641
647
) {
642
648
let mut bar = match verbosity {
643
649
Verbosity :: Quiet | Verbosity :: Spammy => ProgressReport :: hidden ( ) ,
644
- _ if self . parallel || self . output . is_some ( ) => ProgressReport :: hidden ( ) ,
650
+ _ if self . output . is_some ( ) => ProgressReport :: hidden ( ) ,
645
651
_ => ProgressReport :: new ( bodies. len ( ) as u64 ) ,
646
652
} ;
647
653
648
654
let mut sw = self . stop_watch ( ) ;
649
655
bar. tick ( ) ;
650
656
for & body_id in bodies {
651
- let name = body_id. name ( db) . unwrap_or_else ( Name :: missing) ;
652
657
let module = body_id. module ( db) ;
653
- let full_name = || {
658
+ let full_name = move || {
654
659
module
655
660
. krate ( )
656
661
. display_name ( db)
@@ -662,38 +667,45 @@ impl flags::AnalysisStats {
662
667
. into_iter ( )
663
668
. filter_map ( |it| it. name ( db) )
664
669
. rev ( )
665
- . chain ( Some ( name. clone ( ) ) )
670
+ . chain ( Some ( body_id . name ( db ) . unwrap_or_else ( Name :: missing ) ) )
666
671
. map ( |it| it. display ( db) . to_string ( ) ) ,
667
672
)
668
673
. join ( "::" )
669
674
} ;
670
675
if let Some ( only_name) = self . only . as_deref ( ) {
671
- if name. display ( db) . to_string ( ) != only_name && full_name ( ) != only_name {
676
+ if body_id. name ( db) . unwrap_or_else ( Name :: missing) . display ( db) . to_string ( )
677
+ != only_name
678
+ && full_name ( ) != only_name
679
+ {
672
680
continue ;
673
681
}
674
682
}
675
- let mut msg = format ! ( "processing: {}" , full_name( ) ) ;
676
- if verbosity. is_verbose ( ) {
677
- let source = match body_id {
678
- DefWithBody :: Function ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
679
- DefWithBody :: Static ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
680
- DefWithBody :: Const ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
681
- DefWithBody :: Variant ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
682
- DefWithBody :: InTypeConst ( _) => unimplemented ! ( ) ,
683
- } ;
684
- if let Some ( src) = source {
685
- let original_file = src. file_id . original_file ( db) ;
686
- let path = vfs. file_path ( original_file) ;
687
- let syntax_range = src. value . text_range ( ) ;
688
- format_to ! ( msg, " ({} {:?})" , path, syntax_range) ;
683
+ let msg = move || {
684
+ if verbosity. is_verbose ( ) {
685
+ let source = match body_id {
686
+ DefWithBody :: Function ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
687
+ DefWithBody :: Static ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
688
+ DefWithBody :: Const ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
689
+ DefWithBody :: Variant ( it) => it. source ( db) . map ( |it| it. syntax ( ) . cloned ( ) ) ,
690
+ DefWithBody :: InTypeConst ( _) => unimplemented ! ( ) ,
691
+ } ;
692
+ if let Some ( src) = source {
693
+ let original_file = src. file_id . original_file ( db) ;
694
+ let path = vfs. file_path ( original_file) ;
695
+ let syntax_range = src. value . text_range ( ) ;
696
+ format ! ( "processing: {} ({} {:?})" , full_name( ) , path, syntax_range)
697
+ } else {
698
+ format ! ( "processing: {}" , full_name( ) )
699
+ }
700
+ } else {
701
+ format ! ( "processing: {}" , full_name( ) )
689
702
}
690
- }
703
+ } ;
691
704
if verbosity. is_spammy ( ) {
692
- bar. println ( msg. to_string ( ) ) ;
705
+ bar. println ( msg ( ) ) ;
693
706
}
694
- bar. set_message ( & msg) ;
695
- let ( body, sm) = db. body_with_source_map ( body_id. into ( ) ) ;
696
- // endregion:patterns
707
+ bar. set_message ( msg) ;
708
+ db. body_with_source_map ( body_id. into ( ) ) ;
697
709
bar. inc ( 1 ) ;
698
710
}
699
711
0 commit comments