@@ -397,25 +397,19 @@ impl GlobalState {
397397 tracing:: debug!( %cause, "will prime caches" ) ;
398398 let num_worker_threads = self . config . prime_caches_num_threads ( ) ;
399399
400- self . task_pool . handle . spawn_with_sender (
401- stdx:: thread:: ThreadIntent :: Worker ,
402- "prime_caches" ,
403- {
404- let analysis = self . snapshot ( ) . analysis ;
405- move |sender| {
406- sender. send ( Task :: PrimeCaches ( PrimeCachesProgress :: Begin ) ) . unwrap ( ) ;
407- let res = analysis. parallel_prime_caches ( num_worker_threads, |progress| {
408- let report = PrimeCachesProgress :: Report ( progress) ;
409- sender. send ( Task :: PrimeCaches ( report) ) . unwrap ( ) ;
410- } ) ;
411- sender
412- . send ( Task :: PrimeCaches ( PrimeCachesProgress :: End {
413- cancelled : res. is_err ( ) ,
414- } ) )
415- . unwrap ( ) ;
416- }
417- } ,
418- ) ;
400+ self . task_pool . handle . spawn_with_sender ( stdx:: thread:: ThreadIntent :: Worker , {
401+ let analysis = self . snapshot ( ) . analysis ;
402+ move |sender| {
403+ sender. send ( Task :: PrimeCaches ( PrimeCachesProgress :: Begin ) ) . unwrap ( ) ;
404+ let res = analysis. parallel_prime_caches ( num_worker_threads, |progress| {
405+ let report = PrimeCachesProgress :: Report ( progress) ;
406+ sender. send ( Task :: PrimeCaches ( report) ) . unwrap ( ) ;
407+ } ) ;
408+ sender
409+ . send ( Task :: PrimeCaches ( PrimeCachesProgress :: End { cancelled : res. is_err ( ) } ) )
410+ . unwrap ( ) ;
411+ }
412+ } ) ;
419413 }
420414
421415 fn update_status_or_notify ( & mut self ) {
@@ -802,62 +796,56 @@ impl GlobalState {
802796
803797 // Diagnostics are triggered by the user typing
804798 // so we run them on a latency sensitive thread.
805- self . task_pool . handle . spawn (
806- stdx:: thread:: ThreadIntent :: LatencySensitive ,
807- "publish_diagnostics" ,
808- move || {
809- let _p = profile:: span ( "publish_diagnostics" ) ;
810- let diagnostics = subscriptions
811- . into_iter ( )
812- . filter_map ( |file_id| {
813- let line_index = snapshot. file_line_index ( file_id) . ok ( ) ?;
814- Some ( (
815- file_id,
816- line_index,
817- snapshot
818- . analysis
819- . diagnostics (
820- & snapshot. config . diagnostics ( ) ,
821- ide:: AssistResolveStrategy :: None ,
822- file_id,
823- )
824- . ok ( ) ?,
825- ) )
826- } )
827- . map ( |( file_id, line_index, it) | {
828- (
829- file_id,
830- it. into_iter ( )
831- . map ( move |d| lsp_types:: Diagnostic {
832- range : crate :: to_proto:: range ( & line_index, d. range ) ,
833- severity : Some ( crate :: to_proto:: diagnostic_severity (
834- d. severity ,
835- ) ) ,
836- code : Some ( lsp_types:: NumberOrString :: String (
837- d. code . as_str ( ) . to_string ( ) ,
838- ) ) ,
839- code_description : Some ( lsp_types:: CodeDescription {
840- href : lsp_types:: Url :: parse ( & format ! (
841- "https://rust-analyzer.github.io/manual.html#{}" ,
842- d. code. as_str( )
843- ) )
844- . unwrap ( ) ,
845- } ) ,
846- source : Some ( "rust-analyzer" . to_string ( ) ) ,
847- message : d. message ,
848- related_information : None ,
849- tags : if d. unused {
850- Some ( vec ! [ lsp_types:: DiagnosticTag :: UNNECESSARY ] )
851- } else {
852- None
853- } ,
854- data : None ,
855- } )
856- . collect :: < Vec < _ > > ( ) ,
857- )
858- } ) ;
859- Task :: Diagnostics ( diagnostics. collect ( ) )
860- } ,
861- ) ;
799+ self . task_pool . handle . spawn ( stdx:: thread:: ThreadIntent :: LatencySensitive , move || {
800+ let _p = profile:: span ( "publish_diagnostics" ) ;
801+ let diagnostics = subscriptions
802+ . into_iter ( )
803+ . filter_map ( |file_id| {
804+ let line_index = snapshot. file_line_index ( file_id) . ok ( ) ?;
805+ Some ( (
806+ file_id,
807+ line_index,
808+ snapshot
809+ . analysis
810+ . diagnostics (
811+ & snapshot. config . diagnostics ( ) ,
812+ ide:: AssistResolveStrategy :: None ,
813+ file_id,
814+ )
815+ . ok ( ) ?,
816+ ) )
817+ } )
818+ . map ( |( file_id, line_index, it) | {
819+ (
820+ file_id,
821+ it. into_iter ( )
822+ . map ( move |d| lsp_types:: Diagnostic {
823+ range : crate :: to_proto:: range ( & line_index, d. range ) ,
824+ severity : Some ( crate :: to_proto:: diagnostic_severity ( d. severity ) ) ,
825+ code : Some ( lsp_types:: NumberOrString :: String (
826+ d. code . as_str ( ) . to_string ( ) ,
827+ ) ) ,
828+ code_description : Some ( lsp_types:: CodeDescription {
829+ href : lsp_types:: Url :: parse ( & format ! (
830+ "https://rust-analyzer.github.io/manual.html#{}" ,
831+ d. code. as_str( )
832+ ) )
833+ . unwrap ( ) ,
834+ } ) ,
835+ source : Some ( "rust-analyzer" . to_string ( ) ) ,
836+ message : d. message ,
837+ related_information : None ,
838+ tags : if d. unused {
839+ Some ( vec ! [ lsp_types:: DiagnosticTag :: UNNECESSARY ] )
840+ } else {
841+ None
842+ } ,
843+ data : None ,
844+ } )
845+ . collect :: < Vec < _ > > ( ) ,
846+ )
847+ } ) ;
848+ Task :: Diagnostics ( diagnostics. collect ( ) )
849+ } ) ;
862850 }
863851}
0 commit comments