aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock42
-rw-r--r--crates/profile/Cargo.toml (renamed from crates/ra_prof/Cargo.toml)14
-rw-r--r--crates/profile/src/google_cpu_profiler.rs (renamed from crates/ra_prof/src/google_cpu_profiler.rs)0
-rw-r--r--crates/profile/src/hprof.rs (renamed from crates/ra_prof/src/hprof.rs)21
-rw-r--r--crates/profile/src/lib.rs (renamed from crates/ra_prof/src/lib.rs)12
-rw-r--r--crates/profile/src/memory_usage.rs (renamed from crates/ra_prof/src/memory_usage.rs)0
-rw-r--r--crates/profile/src/stop_watch.rs (renamed from crates/ra_prof/src/stop_watch.rs)0
-rw-r--r--crates/profile/src/tree.rs (renamed from crates/ra_prof/src/tree.rs)0
-rw-r--r--crates/ra_assists/Cargo.toml2
-rw-r--r--crates/ra_assists/src/handlers/add_missing_impl_members.rs2
-rw-r--r--crates/ra_assists/src/handlers/auto_import.rs3
-rw-r--r--crates/ra_db/Cargo.toml2
-rw-r--r--crates/ra_db/src/lib.rs3
-rw-r--r--crates/ra_hir/Cargo.toml2
-rw-r--r--crates/ra_hir/src/code_model.rs3
-rw-r--r--crates/ra_hir/src/semantics.rs5
-rw-r--r--crates/ra_hir/src/semantics/source_to_def.rs5
-rw-r--r--crates/ra_hir_def/Cargo.toml2
-rw-r--r--crates/ra_hir_def/src/body.rs3
-rw-r--r--crates/ra_hir_def/src/data.rs3
-rw-r--r--crates/ra_hir_def/src/db.rs3
-rw-r--r--crates/ra_hir_def/src/find_path.rs5
-rw-r--r--crates/ra_hir_def/src/generics.rs3
-rw-r--r--crates/ra_hir_def/src/import_map.rs4
-rw-r--r--crates/ra_hir_def/src/item_tree.rs2
-rw-r--r--crates/ra_hir_def/src/lang_item.rs7
-rw-r--r--crates/ra_hir_def/src/nameres.rs3
-rw-r--r--crates/ra_hir_expand/Cargo.toml2
-rw-r--r--crates/ra_hir_expand/src/db.rs3
-rw-r--r--crates/ra_hir_ty/Cargo.toml2
-rw-r--r--crates/ra_hir_ty/src/db.rs3
-rw-r--r--crates/ra_hir_ty/src/diagnostics.rs3
-rw-r--r--crates/ra_hir_ty/src/infer.rs3
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs5
-rw-r--r--crates/ra_hir_ty/src/traits.rs3
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs2
-rw-r--r--crates/ra_ide/Cargo.toml2
-rw-r--r--crates/ra_ide/src/diagnostics.rs3
-rw-r--r--crates/ra_ide/src/inlay_hints.rs3
-rw-r--r--crates/ra_ide/src/lib.rs2
-rw-r--r--crates/ra_ide/src/references.rs3
-rw-r--r--crates/ra_ide/src/status.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs3
-rw-r--r--crates/ra_ide_db/Cargo.toml2
-rw-r--r--crates/ra_ide_db/src/change.rs8
-rw-r--r--crates/ra_ide_db/src/defs.rs5
-rw-r--r--crates/ra_ide_db/src/imports_locator.rs5
-rw-r--r--crates/ra_ide_db/src/search.rs5
-rw-r--r--crates/ra_ide_db/src/symbol_index.rs5
-rw-r--r--crates/rust-analyzer/Cargo.toml2
-rw-r--r--crates/rust-analyzer/src/bin/main.rs2
-rw-r--r--crates/rust-analyzer/src/cli.rs3
-rw-r--r--crates/rust-analyzer/src/cli/analysis_bench.rs2
-rw-r--r--crates/rust-analyzer/src/cli/analysis_stats.rs2
-rw-r--r--crates/rust-analyzer/src/global_state.rs3
-rw-r--r--crates/rust-analyzer/src/handlers.rs77
-rw-r--r--crates/rust-analyzer/src/lib.rs10
-rw-r--r--crates/rust-analyzer/src/main_loop.rs5
-rw-r--r--crates/rust-analyzer/src/reload.rs7
-rw-r--r--crates/rust-analyzer/tests/heavy_tests/support.rs2
-rw-r--r--xtask/tests/tidy.rs2
61 files changed, 154 insertions, 188 deletions
diff --git a/Cargo.lock b/Cargo.lock
index ab1698b11..c2a0457c7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -895,6 +895,18 @@ dependencies = [
895] 895]
896 896
897[[package]] 897[[package]]
898name = "profile"
899version = "0.0.0"
900dependencies = [
901 "arena",
902 "backtrace",
903 "cfg-if",
904 "libc",
905 "once_cell",
906 "perf-event",
907]
908
909[[package]]
898name = "quote" 910name = "quote"
899version = "1.0.7" 911version = "1.0.7"
900source = "registry+https://github.com/rust-lang/crates.io-index" 912source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -909,11 +921,11 @@ version = "0.1.0"
909dependencies = [ 921dependencies = [
910 "either", 922 "either",
911 "itertools", 923 "itertools",
924 "profile",
912 "ra_db", 925 "ra_db",
913 "ra_fmt", 926 "ra_fmt",
914 "ra_hir", 927 "ra_hir",
915 "ra_ide_db", 928 "ra_ide_db",
916 "ra_prof",
917 "ra_syntax", 929 "ra_syntax",
918 "ra_text_edit", 930 "ra_text_edit",
919 "rustc-hash", 931 "rustc-hash",
@@ -935,8 +947,8 @@ dependencies = [
935name = "ra_db" 947name = "ra_db"
936version = "0.1.0" 948version = "0.1.0"
937dependencies = [ 949dependencies = [
950 "profile",
938 "ra_cfg", 951 "ra_cfg",
939 "ra_prof",
940 "ra_syntax", 952 "ra_syntax",
941 "ra_tt", 953 "ra_tt",
942 "rustc-hash", 954 "rustc-hash",
@@ -962,11 +974,11 @@ dependencies = [
962 "either", 974 "either",
963 "itertools", 975 "itertools",
964 "log", 976 "log",
977 "profile",
965 "ra_db", 978 "ra_db",
966 "ra_hir_def", 979 "ra_hir_def",
967 "ra_hir_expand", 980 "ra_hir_expand",
968 "ra_hir_ty", 981 "ra_hir_ty",
969 "ra_prof",
970 "ra_syntax", 982 "ra_syntax",
971 "rustc-hash", 983 "rustc-hash",
972 "stdx", 984 "stdx",
@@ -986,11 +998,11 @@ dependencies = [
986 "itertools", 998 "itertools",
987 "log", 999 "log",
988 "once_cell", 1000 "once_cell",
1001 "profile",
989 "ra_cfg", 1002 "ra_cfg",
990 "ra_db", 1003 "ra_db",
991 "ra_hir_expand", 1004 "ra_hir_expand",
992 "ra_mbe", 1005 "ra_mbe",
993 "ra_prof",
994 "ra_syntax", 1006 "ra_syntax",
995 "ra_tt", 1007 "ra_tt",
996 "rustc-hash", 1008 "rustc-hash",
@@ -1006,10 +1018,10 @@ dependencies = [
1006 "arena", 1018 "arena",
1007 "either", 1019 "either",
1008 "log", 1020 "log",
1021 "profile",
1009 "ra_db", 1022 "ra_db",
1010 "ra_mbe", 1023 "ra_mbe",
1011 "ra_parser", 1024 "ra_parser",
1012 "ra_prof",
1013 "ra_syntax", 1025 "ra_syntax",
1014 "ra_tt", 1026 "ra_tt",
1015 "rustc-hash", 1027 "rustc-hash",
@@ -1029,10 +1041,10 @@ dependencies = [
1029 "expect", 1041 "expect",
1030 "itertools", 1042 "itertools",
1031 "log", 1043 "log",
1044 "profile",
1032 "ra_db", 1045 "ra_db",
1033 "ra_hir_def", 1046 "ra_hir_def",
1034 "ra_hir_expand", 1047 "ra_hir_expand",
1035 "ra_prof",
1036 "ra_syntax", 1048 "ra_syntax",
1037 "rustc-hash", 1049 "rustc-hash",
1038 "scoped-tls", 1050 "scoped-tls",
@@ -1054,13 +1066,13 @@ dependencies = [
1054 "itertools", 1066 "itertools",
1055 "log", 1067 "log",
1056 "oorandom", 1068 "oorandom",
1069 "profile",
1057 "ra_assists", 1070 "ra_assists",
1058 "ra_cfg", 1071 "ra_cfg",
1059 "ra_db", 1072 "ra_db",
1060 "ra_fmt", 1073 "ra_fmt",
1061 "ra_hir", 1074 "ra_hir",
1062 "ra_ide_db", 1075 "ra_ide_db",
1063 "ra_prof",
1064 "ra_ssr", 1076 "ra_ssr",
1065 "ra_syntax", 1077 "ra_syntax",
1066 "ra_text_edit", 1078 "ra_text_edit",
@@ -1077,9 +1089,9 @@ dependencies = [
1077 "fst", 1089 "fst",
1078 "log", 1090 "log",
1079 "once_cell", 1091 "once_cell",
1092 "profile",
1080 "ra_db", 1093 "ra_db",
1081 "ra_hir", 1094 "ra_hir",
1082 "ra_prof",
1083 "ra_syntax", 1095 "ra_syntax",
1084 "ra_text_edit", 1096 "ra_text_edit",
1085 "rayon", 1097 "rayon",
@@ -1138,18 +1150,6 @@ dependencies = [
1138] 1150]
1139 1151
1140[[package]] 1152[[package]]
1141name = "ra_prof"
1142version = "0.1.0"
1143dependencies = [
1144 "arena",
1145 "backtrace",
1146 "cfg-if",
1147 "libc",
1148 "once_cell",
1149 "perf-event",
1150]
1151
1152[[package]]
1153name = "ra_project_model" 1153name = "ra_project_model"
1154version = "0.1.0" 1154version = "0.1.0"
1155dependencies = [ 1155dependencies = [
@@ -1314,6 +1314,7 @@ dependencies = [
1314 "oorandom", 1314 "oorandom",
1315 "parking_lot", 1315 "parking_lot",
1316 "pico-args", 1316 "pico-args",
1317 "profile",
1317 "ra_cfg", 1318 "ra_cfg",
1318 "ra_db", 1319 "ra_db",
1319 "ra_hir", 1320 "ra_hir",
@@ -1323,7 +1324,6 @@ dependencies = [
1323 "ra_ide_db", 1324 "ra_ide_db",
1324 "ra_mbe", 1325 "ra_mbe",
1325 "ra_proc_macro_srv", 1326 "ra_proc_macro_srv",
1326 "ra_prof",
1327 "ra_project_model", 1327 "ra_project_model",
1328 "ra_ssr", 1328 "ra_ssr",
1329 "ra_syntax", 1329 "ra_syntax",
diff --git a/crates/ra_prof/Cargo.toml b/crates/profile/Cargo.toml
index 9880c587f..e271e3a56 100644
--- a/crates/ra_prof/Cargo.toml
+++ b/crates/profile/Cargo.toml
@@ -1,20 +1,20 @@
1[package] 1[package]
2edition = "2018" 2name = "profile"
3name = "ra_prof" 3version = "0.0.0"
4version = "0.1.0"
5authors = ["rust-analyzer developers"]
6publish = false
7license = "MIT OR Apache-2.0" 4license = "MIT OR Apache-2.0"
5authors = ["rust-analyzer developers"]
6edition = "2018"
8 7
9[lib] 8[lib]
10doctest = false 9doctest = false
11 10
12[dependencies] 11[dependencies]
13arena = { path = "../arena" }
14once_cell = "1.3.1" 12once_cell = "1.3.1"
15backtrace = { version = "0.3.44", optional = true }
16cfg-if = "0.1.10" 13cfg-if = "0.1.10"
17libc = "0.2.73" 14libc = "0.2.73"
15backtrace = { version = "0.3.44", optional = true }
16
17arena = { path = "../arena" }
18 18
19[target.'cfg(target_os = "linux")'.dependencies] 19[target.'cfg(target_os = "linux")'.dependencies]
20perf-event = "0.4" 20perf-event = "0.4"
diff --git a/crates/ra_prof/src/google_cpu_profiler.rs b/crates/profile/src/google_cpu_profiler.rs
index db865c65b..db865c65b 100644
--- a/crates/ra_prof/src/google_cpu_profiler.rs
+++ b/crates/profile/src/google_cpu_profiler.rs
diff --git a/crates/ra_prof/src/hprof.rs b/crates/profile/src/hprof.rs
index a3f5321fb..934cc8e37 100644
--- a/crates/ra_prof/src/hprof.rs
+++ b/crates/profile/src/hprof.rs
@@ -37,19 +37,16 @@ pub type Label = &'static str;
37/// 37///
38/// # Example 38/// # Example
39/// ``` 39/// ```
40/// use ra_prof::{profile, set_filter, Filter}; 40/// profile::init_from("profile1|profile2@2");
41///
42/// let f = Filter::from_spec("profile1|profile2@2");
43/// set_filter(f);
44/// profiling_function1(); 41/// profiling_function1();
45/// 42///
46/// fn profiling_function1() { 43/// fn profiling_function1() {
47/// let _p = profile("profile1"); 44/// let _p = profile::span("profile1");
48/// profiling_function2(); 45/// profiling_function2();
49/// } 46/// }
50/// 47///
51/// fn profiling_function2() { 48/// fn profiling_function2() {
52/// let _p = profile("profile2"); 49/// let _p = profile::span("profile2");
53/// } 50/// }
54/// ``` 51/// ```
55/// This will print in the stderr the following: 52/// This will print in the stderr the following:
@@ -57,27 +54,27 @@ pub type Label = &'static str;
57/// 0ms - profile 54/// 0ms - profile
58/// 0ms - profile2 55/// 0ms - profile2
59/// ``` 56/// ```
60pub fn profile(label: Label) -> Profiler { 57pub fn span(label: Label) -> ProfileSpan {
61 assert!(!label.is_empty()); 58 assert!(!label.is_empty());
62 59
63 if PROFILING_ENABLED.load(Ordering::Relaxed) 60 if PROFILING_ENABLED.load(Ordering::Relaxed)
64 && PROFILE_STACK.with(|stack| stack.borrow_mut().push(label)) 61 && PROFILE_STACK.with(|stack| stack.borrow_mut().push(label))
65 { 62 {
66 Profiler(Some(ProfilerImpl { label, detail: None })) 63 ProfileSpan(Some(ProfilerImpl { label, detail: None }))
67 } else { 64 } else {
68 Profiler(None) 65 ProfileSpan(None)
69 } 66 }
70} 67}
71 68
72pub struct Profiler(Option<ProfilerImpl>); 69pub struct ProfileSpan(Option<ProfilerImpl>);
73 70
74struct ProfilerImpl { 71struct ProfilerImpl {
75 label: Label, 72 label: Label,
76 detail: Option<String>, 73 detail: Option<String>,
77} 74}
78 75
79impl Profiler { 76impl ProfileSpan {
80 pub fn detail(mut self, detail: impl FnOnce() -> String) -> Profiler { 77 pub fn detail(mut self, detail: impl FnOnce() -> String) -> ProfileSpan {
81 if let Some(profiler) = &mut self.0 { 78 if let Some(profiler) = &mut self.0 {
82 profiler.detail = Some(detail()) 79 profiler.detail = Some(detail())
83 } 80 }
diff --git a/crates/ra_prof/src/lib.rs b/crates/profile/src/lib.rs
index eb50965ae..ab19271c7 100644
--- a/crates/ra_prof/src/lib.rs
+++ b/crates/profile/src/lib.rs
@@ -10,7 +10,7 @@ mod tree;
10use std::cell::RefCell; 10use std::cell::RefCell;
11 11
12pub use crate::{ 12pub use crate::{
13 hprof::{init, init_from, profile}, 13 hprof::{init, init_from, span},
14 memory_usage::{Bytes, MemoryUsage}, 14 memory_usage::{Bytes, MemoryUsage},
15 stop_watch::{StopWatch, StopWatchSpan}, 15 stop_watch::{StopWatch, StopWatchSpan},
16}; 16};
@@ -25,7 +25,7 @@ pub fn print_backtrace() {
25pub fn print_backtrace() { 25pub fn print_backtrace() {
26 eprintln!( 26 eprintln!(
27 r#"enable the backtrace feature: 27 r#"enable the backtrace feature:
28 ra_prof = {{ path = "../ra_prof", features = [ "backtrace"] }} 28 profile = {{ path = "../profile", features = [ "backtrace"] }}
29"# 29"#
30 ); 30 );
31} 31}
@@ -76,12 +76,12 @@ impl Drop for Scope {
76/// 76///
77/// https://github.com/rust-analyzer/rust-analyzer/pull/5306 77/// https://github.com/rust-analyzer/rust-analyzer/pull/5306
78#[derive(Debug)] 78#[derive(Debug)]
79pub struct CpuProfiler { 79pub struct CpuSpan {
80 _private: (), 80 _private: (),
81} 81}
82 82
83#[must_use] 83#[must_use]
84pub fn cpu_profiler() -> CpuProfiler { 84pub fn cpu_span() -> CpuSpan {
85 #[cfg(feature = "cpu_profiler")] 85 #[cfg(feature = "cpu_profiler")]
86 { 86 {
87 google_cpu_profiler::start("./out.profile".as_ref()) 87 google_cpu_profiler::start("./out.profile".as_ref())
@@ -92,10 +92,10 @@ pub fn cpu_profiler() -> CpuProfiler {
92 eprintln!("cpu_profiler feature is disabled") 92 eprintln!("cpu_profiler feature is disabled")
93 } 93 }
94 94
95 CpuProfiler { _private: () } 95 CpuSpan { _private: () }
96} 96}
97 97
98impl Drop for CpuProfiler { 98impl Drop for CpuSpan {
99 fn drop(&mut self) { 99 fn drop(&mut self) {
100 #[cfg(feature = "cpu_profiler")] 100 #[cfg(feature = "cpu_profiler")]
101 { 101 {
diff --git a/crates/ra_prof/src/memory_usage.rs b/crates/profile/src/memory_usage.rs
index 83390212a..83390212a 100644
--- a/crates/ra_prof/src/memory_usage.rs
+++ b/crates/profile/src/memory_usage.rs
diff --git a/crates/ra_prof/src/stop_watch.rs b/crates/profile/src/stop_watch.rs
index 5e276190e..5e276190e 100644
--- a/crates/ra_prof/src/stop_watch.rs
+++ b/crates/profile/src/stop_watch.rs
diff --git a/crates/ra_prof/src/tree.rs b/crates/profile/src/tree.rs
index 096f58511..096f58511 100644
--- a/crates/ra_prof/src/tree.rs
+++ b/crates/profile/src/tree.rs
diff --git a/crates/ra_assists/Cargo.toml b/crates/ra_assists/Cargo.toml
index bd2905f08..6f5ace941 100644
--- a/crates/ra_assists/Cargo.toml
+++ b/crates/ra_assists/Cargo.toml
@@ -18,7 +18,7 @@ stdx = { path = "../stdx" }
18ra_syntax = { path = "../ra_syntax" } 18ra_syntax = { path = "../ra_syntax" }
19ra_text_edit = { path = "../ra_text_edit" } 19ra_text_edit = { path = "../ra_text_edit" }
20ra_fmt = { path = "../ra_fmt" } 20ra_fmt = { path = "../ra_fmt" }
21ra_prof = { path = "../ra_prof" } 21profile = { path = "../profile" }
22ra_db = { path = "../ra_db" } 22ra_db = { path = "../ra_db" }
23ra_ide_db = { path = "../ra_ide_db" } 23ra_ide_db = { path = "../ra_ide_db" }
24hir = { path = "../ra_hir", package = "ra_hir" } 24hir = { path = "../ra_hir", package = "ra_hir" }
diff --git a/crates/ra_assists/src/handlers/add_missing_impl_members.rs b/crates/ra_assists/src/handlers/add_missing_impl_members.rs
index 95a750aee..dd1406228 100644
--- a/crates/ra_assists/src/handlers/add_missing_impl_members.rs
+++ b/crates/ra_assists/src/handlers/add_missing_impl_members.rs
@@ -110,7 +110,7 @@ fn add_missing_impl_members_inner(
110 assist_id: &'static str, 110 assist_id: &'static str,
111 label: &'static str, 111 label: &'static str,
112) -> Option<()> { 112) -> Option<()> {
113 let _p = ra_prof::profile("add_missing_impl_members_inner"); 113 let _p = profile::span("add_missing_impl_members_inner");
114 let impl_def = ctx.find_node_at_offset::<ast::Impl>()?; 114 let impl_def = ctx.find_node_at_offset::<ast::Impl>()?;
115 let impl_item_list = impl_def.assoc_item_list()?; 115 let impl_item_list = impl_def.assoc_item_list()?;
116 116
diff --git a/crates/ra_assists/src/handlers/auto_import.rs b/crates/ra_assists/src/handlers/auto_import.rs
index 01e7b7a44..6ec59ec4d 100644
--- a/crates/ra_assists/src/handlers/auto_import.rs
+++ b/crates/ra_assists/src/handlers/auto_import.rs
@@ -6,7 +6,6 @@ use hir::{
6 Type, 6 Type,
7}; 7};
8use ra_ide_db::{imports_locator, RootDatabase}; 8use ra_ide_db::{imports_locator, RootDatabase};
9use ra_prof::profile;
10use ra_syntax::{ 9use ra_syntax::{
11 ast::{self, AstNode}, 10 ast::{self, AstNode},
12 SyntaxNode, 11 SyntaxNode,
@@ -130,7 +129,7 @@ impl AutoImportAssets {
130 } 129 }
131 130
132 fn search_for_imports(&self, ctx: &AssistContext) -> BTreeSet<ModPath> { 131 fn search_for_imports(&self, ctx: &AssistContext) -> BTreeSet<ModPath> {
133 let _p = profile("auto_import::search_for_imports"); 132 let _p = profile::span("auto_import::search_for_imports");
134 let db = ctx.db(); 133 let db = ctx.db();
135 let current_crate = self.module_with_name_to_import.krate(); 134 let current_crate = self.module_with_name_to_import.krate();
136 imports_locator::find_imports(&ctx.sema, current_crate, &self.get_search_query()) 135 imports_locator::find_imports(&ctx.sema, current_crate, &self.get_search_query())
diff --git a/crates/ra_db/Cargo.toml b/crates/ra_db/Cargo.toml
index fe73dc015..9cb9ba11c 100644
--- a/crates/ra_db/Cargo.toml
+++ b/crates/ra_db/Cargo.toml
@@ -14,7 +14,7 @@ rustc-hash = "1.1.0"
14 14
15ra_syntax = { path = "../ra_syntax" } 15ra_syntax = { path = "../ra_syntax" }
16ra_cfg = { path = "../ra_cfg" } 16ra_cfg = { path = "../ra_cfg" }
17ra_prof = { path = "../ra_prof" } 17profile = { path = "../profile" }
18ra_tt = { path = "../ra_tt" } 18ra_tt = { path = "../ra_tt" }
19test_utils = { path = "../test_utils" } 19test_utils = { path = "../test_utils" }
20vfs = { path = "../vfs" } 20vfs = { path = "../vfs" }
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index f25be24fe..795d7d2b6 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -5,7 +5,6 @@ pub mod fixture;
5 5
6use std::{panic, sync::Arc}; 6use std::{panic, sync::Arc};
7 7
8use ra_prof::profile;
9use ra_syntax::{ast, Parse, SourceFile, TextRange, TextSize}; 8use ra_syntax::{ast, Parse, SourceFile, TextRange, TextSize};
10use rustc_hash::FxHashSet; 9use rustc_hash::FxHashSet;
11 10
@@ -113,7 +112,7 @@ pub trait SourceDatabase: CheckCanceled + FileLoader + std::fmt::Debug {
113} 112}
114 113
115fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> { 114fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
116 let _p = profile("parse_query").detail(|| format!("{:?}", file_id)); 115 let _p = profile::span("parse_query").detail(|| format!("{:?}", file_id));
117 let text = db.file_text(file_id); 116 let text = db.file_text(file_id);
118 SourceFile::parse(&*text) 117 SourceFile::parse(&*text)
119} 118}
diff --git a/crates/ra_hir/Cargo.toml b/crates/ra_hir/Cargo.toml
index c260bb193..903406e84 100644
--- a/crates/ra_hir/Cargo.toml
+++ b/crates/ra_hir/Cargo.toml
@@ -19,7 +19,7 @@ itertools = "0.9.0"
19stdx = { path = "../stdx" } 19stdx = { path = "../stdx" }
20ra_syntax = { path = "../ra_syntax" } 20ra_syntax = { path = "../ra_syntax" }
21ra_db = { path = "../ra_db" } 21ra_db = { path = "../ra_db" }
22ra_prof = { path = "../ra_prof" } 22profile = { path = "../profile" }
23hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } 23hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" }
24hir_def = { path = "../ra_hir_def", package = "ra_hir_def" } 24hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
25hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" } 25hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" }
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 0007d7fa8..5c0c6184a 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -31,7 +31,6 @@ use hir_ty::{
31 InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor, 31 InEnvironment, Substs, TraitEnvironment, Ty, TyDefId, TypeCtor,
32}; 32};
33use ra_db::{CrateId, Edition, FileId}; 33use ra_db::{CrateId, Edition, FileId};
34use ra_prof::profile;
35use ra_syntax::{ 34use ra_syntax::{
36 ast::{self, AttrsOwner, NameOwner}, 35 ast::{self, AttrsOwner, NameOwner},
37 AstNode, 36 AstNode,
@@ -304,7 +303,7 @@ impl Module {
304 } 303 }
305 304
306 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { 305 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
307 let _p = profile("Module::diagnostics"); 306 let _p = profile::span("Module::diagnostics");
308 let crate_def_map = db.crate_def_map(self.id.krate); 307 let crate_def_map = db.crate_def_map(self.id.krate);
309 crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink); 308 crate_def_map.add_diagnostics(db.upcast(), self.id.local_id, sink);
310 for decl in self.declarations(db) { 309 for decl in self.declarations(db) {
diff --git a/crates/ra_hir/src/semantics.rs b/crates/ra_hir/src/semantics.rs
index 36b688ccb..7e3ec6315 100644
--- a/crates/ra_hir/src/semantics.rs
+++ b/crates/ra_hir/src/semantics.rs
@@ -12,7 +12,6 @@ use hir_expand::{hygiene::Hygiene, name::AsName, ExpansionInfo};
12use hir_ty::associated_type_shorthand_candidates; 12use hir_ty::associated_type_shorthand_candidates;
13use itertools::Itertools; 13use itertools::Itertools;
14use ra_db::{FileId, FileRange}; 14use ra_db::{FileId, FileRange};
15use ra_prof::profile;
16use ra_syntax::{ 15use ra_syntax::{
17 algo::{find_node_at_offset, skip_trivia_token}, 16 algo::{find_node_at_offset, skip_trivia_token},
18 ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize, 17 ast, AstNode, Direction, SyntaxNode, SyntaxToken, TextRange, TextSize,
@@ -334,7 +333,7 @@ impl<'db> SemanticsImpl<'db> {
334 } 333 }
335 334
336 fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken { 335 fn descend_into_macros(&self, token: SyntaxToken) -> SyntaxToken {
337 let _p = profile("descend_into_macros"); 336 let _p = profile::span("descend_into_macros");
338 let parent = token.parent(); 337 let parent = token.parent();
339 let parent = self.find_file(parent); 338 let parent = self.find_file(parent);
340 let sa = self.analyze2(parent.as_ref(), None); 339 let sa = self.analyze2(parent.as_ref(), None);
@@ -523,7 +522,7 @@ impl<'db> SemanticsImpl<'db> {
523 } 522 }
524 523
525 fn analyze2(&self, src: InFile<&SyntaxNode>, offset: Option<TextSize>) -> SourceAnalyzer { 524 fn analyze2(&self, src: InFile<&SyntaxNode>, offset: Option<TextSize>) -> SourceAnalyzer {
526 let _p = profile("Semantics::analyze2"); 525 let _p = profile::span("Semantics::analyze2");
527 526
528 let container = match self.with_ctx(|ctx| ctx.find_container(src)) { 527 let container = match self.with_ctx(|ctx| ctx.find_container(src)) {
529 Some(it) => it, 528 Some(it) => it,
diff --git a/crates/ra_hir/src/semantics/source_to_def.rs b/crates/ra_hir/src/semantics/source_to_def.rs
index 863e8e5ff..a6ff8b0bf 100644
--- a/crates/ra_hir/src/semantics/source_to_def.rs
+++ b/crates/ra_hir/src/semantics/source_to_def.rs
@@ -10,7 +10,6 @@ use hir_def::{
10}; 10};
11use hir_expand::{name::AsName, AstId, MacroDefKind}; 11use hir_expand::{name::AsName, AstId, MacroDefKind};
12use ra_db::FileId; 12use ra_db::FileId;
13use ra_prof::profile;
14use ra_syntax::{ 13use ra_syntax::{
15 ast::{self, NameOwner}, 14 ast::{self, NameOwner},
16 match_ast, AstNode, SyntaxNode, 15 match_ast, AstNode, SyntaxNode,
@@ -29,7 +28,7 @@ pub(super) struct SourceToDefCtx<'a, 'b> {
29 28
30impl SourceToDefCtx<'_, '_> { 29impl SourceToDefCtx<'_, '_> {
31 pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> { 30 pub(super) fn file_to_def(&mut self, file: FileId) -> Option<ModuleId> {
32 let _p = profile("SourceBinder::to_module_def"); 31 let _p = profile::span("SourceBinder::to_module_def");
33 let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| { 32 let (krate, local_id) = self.db.relevant_crates(file).iter().find_map(|&crate_id| {
34 let crate_def_map = self.db.crate_def_map(crate_id); 33 let crate_def_map = self.db.crate_def_map(crate_id);
35 let local_id = crate_def_map.modules_for_file(file).next()?; 34 let local_id = crate_def_map.modules_for_file(file).next()?;
@@ -39,7 +38,7 @@ impl SourceToDefCtx<'_, '_> {
39 } 38 }
40 39
41 pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> { 40 pub(super) fn module_to_def(&mut self, src: InFile<ast::Module>) -> Option<ModuleId> {
42 let _p = profile("module_to_def"); 41 let _p = profile::span("module_to_def");
43 let parent_declaration = src 42 let parent_declaration = src
44 .as_ref() 43 .as_ref()
45 .map(|it| it.syntax()) 44 .map(|it| it.syntax())
diff --git a/crates/ra_hir_def/Cargo.toml b/crates/ra_hir_def/Cargo.toml
index 6dd6fdde6..adfd8c7b7 100644
--- a/crates/ra_hir_def/Cargo.toml
+++ b/crates/ra_hir_def/Cargo.toml
@@ -25,7 +25,7 @@ stdx = { path = "../stdx" }
25arena = { path = "../arena" } 25arena = { path = "../arena" }
26ra_db = { path = "../ra_db" } 26ra_db = { path = "../ra_db" }
27ra_syntax = { path = "../ra_syntax" } 27ra_syntax = { path = "../ra_syntax" }
28ra_prof = { path = "../ra_prof" } 28profile = { path = "../profile" }
29hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } 29hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" }
30test_utils = { path = "../test_utils" } 30test_utils = { path = "../test_utils" }
31mbe = { path = "../ra_mbe", package = "ra_mbe" } 31mbe = { path = "../ra_mbe", package = "ra_mbe" }
diff --git a/crates/ra_hir_def/src/body.rs b/crates/ra_hir_def/src/body.rs
index cb178655b..1deb1a837 100644
--- a/crates/ra_hir_def/src/body.rs
+++ b/crates/ra_hir_def/src/body.rs
@@ -11,7 +11,6 @@ use either::Either;
11use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId}; 11use hir_expand::{ast_id_map::AstIdMap, hygiene::Hygiene, AstId, HirFileId, InFile, MacroDefId};
12use ra_cfg::CfgOptions; 12use ra_cfg::CfgOptions;
13use ra_db::CrateId; 13use ra_db::CrateId;
14use ra_prof::profile;
15use ra_syntax::{ast, AstNode, AstPtr}; 14use ra_syntax::{ast, AstNode, AstPtr};
16use rustc_hash::FxHashMap; 15use rustc_hash::FxHashMap;
17use test_utils::mark; 16use test_utils::mark;
@@ -228,7 +227,7 @@ impl Body {
228 db: &dyn DefDatabase, 227 db: &dyn DefDatabase,
229 def: DefWithBodyId, 228 def: DefWithBodyId,
230 ) -> (Arc<Body>, Arc<BodySourceMap>) { 229 ) -> (Arc<Body>, Arc<BodySourceMap>) {
231 let _p = profile("body_with_source_map_query"); 230 let _p = profile::span("body_with_source_map_query");
232 let mut params = None; 231 let mut params = None;
233 232
234 let (file_id, module, body) = match def { 233 let (file_id, module, body) = match def {
diff --git a/crates/ra_hir_def/src/data.rs b/crates/ra_hir_def/src/data.rs
index 88a8ef9bf..758c12f33 100644
--- a/crates/ra_hir_def/src/data.rs
+++ b/crates/ra_hir_def/src/data.rs
@@ -3,7 +3,6 @@
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_expand::{name::Name, InFile}; 5use hir_expand::{name::Name, InFile};
6use ra_prof::profile;
7use ra_syntax::ast; 6use ra_syntax::ast;
8 7
9use crate::{ 8use crate::{
@@ -133,7 +132,7 @@ pub struct ImplData {
133 132
134impl ImplData { 133impl ImplData {
135 pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc<ImplData> { 134 pub(crate) fn impl_data_query(db: &dyn DefDatabase, id: ImplId) -> Arc<ImplData> {
136 let _p = profile("impl_data_query"); 135 let _p = profile::span("impl_data_query");
137 let impl_loc = id.lookup(db); 136 let impl_loc = id.lookup(db);
138 137
139 let item_tree = db.item_tree(impl_loc.id.file_id); 138 let item_tree = db.item_tree(impl_loc.id.file_id);
diff --git a/crates/ra_hir_def/src/db.rs b/crates/ra_hir_def/src/db.rs
index 9c3ede2d7..1dd4197f8 100644
--- a/crates/ra_hir_def/src/db.rs
+++ b/crates/ra_hir_def/src/db.rs
@@ -3,7 +3,6 @@ use std::sync::Arc;
3 3
4use hir_expand::{db::AstDatabase, HirFileId}; 4use hir_expand::{db::AstDatabase, HirFileId};
5use ra_db::{salsa, CrateId, SourceDatabase, Upcast}; 5use ra_db::{salsa, CrateId, SourceDatabase, Upcast};
6use ra_prof::profile;
7use ra_syntax::SmolStr; 6use ra_syntax::SmolStr;
8 7
9use crate::{ 8use crate::{
@@ -116,6 +115,6 @@ pub trait DefDatabase: InternDatabase + AstDatabase + Upcast<dyn AstDatabase> {
116} 115}
117 116
118fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { 117fn crate_def_map_wait(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
119 let _p = profile("crate_def_map:wait"); 118 let _p = profile::span("crate_def_map:wait");
120 db.crate_def_map_query(krate) 119 db.crate_def_map_query(krate)
121} 120}
diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs
index 06701a830..46e70eb48 100644
--- a/crates/ra_hir_def/src/find_path.rs
+++ b/crates/ra_hir_def/src/find_path.rs
@@ -1,7 +1,6 @@
1//! An algorithm to find a path to refer to a certain item. 1//! An algorithm to find a path to refer to a certain item.
2 2
3use hir_expand::name::{known, AsName, Name}; 3use hir_expand::name::{known, AsName, Name};
4use ra_prof::profile;
5use rustc_hash::FxHashSet; 4use rustc_hash::FxHashSet;
6use test_utils::mark; 5use test_utils::mark;
7 6
@@ -18,7 +17,7 @@ use crate::{
18/// Find a path that can be used to refer to a certain item. This can depend on 17/// Find a path that can be used to refer to a certain item. This can depend on
19/// *from where* you're referring to the item, hence the `from` parameter. 18/// *from where* you're referring to the item, hence the `from` parameter.
20pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> { 19pub fn find_path(db: &dyn DefDatabase, item: ItemInNs, from: ModuleId) -> Option<ModPath> {
21 let _p = profile("find_path"); 20 let _p = profile::span("find_path");
22 find_path_inner(db, item, from, MAX_PATH_LEN) 21 find_path_inner(db, item, from, MAX_PATH_LEN)
23} 22}
24 23
@@ -215,7 +214,7 @@ fn find_local_import_locations(
215 item: ItemInNs, 214 item: ItemInNs,
216 from: ModuleId, 215 from: ModuleId,
217) -> Vec<(ModuleId, Name)> { 216) -> Vec<(ModuleId, Name)> {
218 let _p = profile("find_local_import_locations"); 217 let _p = profile::span("find_local_import_locations");
219 218
220 // `from` can import anything below `from` with visibility of at least `from`, and anything 219 // `from` can import anything below `from` with visibility of at least `from`, and anything
221 // above `from` with any visibility. That means we do not need to descend into private siblings 220 // above `from` with any visibility. That means we do not need to descend into private siblings
diff --git a/crates/ra_hir_def/src/generics.rs b/crates/ra_hir_def/src/generics.rs
index 90daa46b4..0e06a0b12 100644
--- a/crates/ra_hir_def/src/generics.rs
+++ b/crates/ra_hir_def/src/generics.rs
@@ -11,7 +11,6 @@ use hir_expand::{
11 InFile, 11 InFile,
12}; 12};
13use ra_db::FileId; 13use ra_db::FileId;
14use ra_prof::profile;
15use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner}; 14use ra_syntax::ast::{self, GenericParamsOwner, NameOwner, TypeBoundsOwner};
16 15
17use crate::{ 16use crate::{
@@ -73,7 +72,7 @@ impl GenericParams {
73 db: &dyn DefDatabase, 72 db: &dyn DefDatabase,
74 def: GenericDefId, 73 def: GenericDefId,
75 ) -> Arc<GenericParams> { 74 ) -> Arc<GenericParams> {
76 let _p = profile("generic_params_query"); 75 let _p = profile::span("generic_params_query");
77 76
78 let generics = match def { 77 let generics = match def {
79 GenericDefId::FunctionId(id) => { 78 GenericDefId::FunctionId(id) => {
diff --git a/crates/ra_hir_def/src/import_map.rs b/crates/ra_hir_def/src/import_map.rs
index 9e4c30b1a..3a9eec887 100644
--- a/crates/ra_hir_def/src/import_map.rs
+++ b/crates/ra_hir_def/src/import_map.rs
@@ -56,7 +56,7 @@ pub struct ImportMap {
56 56
57impl ImportMap { 57impl ImportMap {
58 pub fn import_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<Self> { 58 pub fn import_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<Self> {
59 let _p = ra_prof::profile("import_map_query"); 59 let _p = profile::span("import_map_query");
60 let def_map = db.crate_def_map(krate); 60 let def_map = db.crate_def_map(krate);
61 let mut import_map = Self::default(); 61 let mut import_map = Self::default();
62 62
@@ -254,7 +254,7 @@ pub fn search_dependencies<'a>(
254 krate: CrateId, 254 krate: CrateId,
255 query: Query, 255 query: Query,
256) -> Vec<ItemInNs> { 256) -> Vec<ItemInNs> {
257 let _p = ra_prof::profile("search_dependencies").detail(|| format!("{:?}", query)); 257 let _p = profile::span("search_dependencies").detail(|| format!("{:?}", query));
258 258
259 let graph = db.crate_graph(); 259 let graph = db.crate_graph();
260 let import_maps: Vec<_> = 260 let import_maps: Vec<_> =
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index fc05bb307..104966c7f 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -77,7 +77,7 @@ pub struct ItemTree {
77 77
78impl ItemTree { 78impl ItemTree {
79 pub fn item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> Arc<ItemTree> { 79 pub fn item_tree_query(db: &dyn DefDatabase, file_id: HirFileId) -> Arc<ItemTree> {
80 let _p = ra_prof::profile("item_tree_query").detail(|| format!("{:?}", file_id)); 80 let _p = profile::span("item_tree_query").detail(|| format!("{:?}", file_id));
81 let syntax = if let Some(node) = db.parse_or_expand(file_id) { 81 let syntax = if let Some(node) = db.parse_or_expand(file_id) {
82 node 82 node
83 } else { 83 } else {
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs
index 3516784b8..3631499bf 100644
--- a/crates/ra_hir_def/src/lang_item.rs
+++ b/crates/ra_hir_def/src/lang_item.rs
@@ -4,7 +4,6 @@
4//! features, such as Fn family of traits. 4//! features, such as Fn family of traits.
5use std::sync::Arc; 5use std::sync::Arc;
6 6
7use ra_prof::profile;
8use ra_syntax::SmolStr; 7use ra_syntax::SmolStr;
9use rustc_hash::FxHashMap; 8use rustc_hash::FxHashMap;
10 9
@@ -79,7 +78,7 @@ impl LangItems {
79 78
80 /// Salsa query. This will look for lang items in a specific crate. 79 /// Salsa query. This will look for lang items in a specific crate.
81 pub(crate) fn crate_lang_items_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<LangItems> { 80 pub(crate) fn crate_lang_items_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<LangItems> {
82 let _p = profile("crate_lang_items_query"); 81 let _p = profile::span("crate_lang_items_query");
83 82
84 let mut lang_items = LangItems::default(); 83 let mut lang_items = LangItems::default();
85 84
@@ -98,7 +97,7 @@ impl LangItems {
98 db: &dyn DefDatabase, 97 db: &dyn DefDatabase,
99 module: ModuleId, 98 module: ModuleId,
100 ) -> Option<Arc<LangItems>> { 99 ) -> Option<Arc<LangItems>> {
101 let _p = profile("module_lang_items_query"); 100 let _p = profile::span("module_lang_items_query");
102 let mut lang_items = LangItems::default(); 101 let mut lang_items = LangItems::default();
103 lang_items.collect_lang_items(db, module); 102 lang_items.collect_lang_items(db, module);
104 if lang_items.items.is_empty() { 103 if lang_items.items.is_empty() {
@@ -115,7 +114,7 @@ impl LangItems {
115 start_crate: CrateId, 114 start_crate: CrateId,
116 item: SmolStr, 115 item: SmolStr,
117 ) -> Option<LangItemTarget> { 116 ) -> Option<LangItemTarget> {
118 let _p = profile("lang_item_query"); 117 let _p = profile::span("lang_item_query");
119 let lang_items = db.crate_lang_items(start_crate); 118 let lang_items = db.crate_lang_items(start_crate);
120 let start_crate_target = lang_items.items.get(&item); 119 let start_crate_target = lang_items.items.get(&item);
121 if let Some(target) = start_crate_target { 120 if let Some(target) = start_crate_target {
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index b4b97eb08..dc239997f 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -59,7 +59,6 @@ use std::sync::Arc;
59use arena::Arena; 59use arena::Arena;
60use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile}; 60use hir_expand::{diagnostics::DiagnosticSink, name::Name, InFile};
61use ra_db::{CrateId, Edition, FileId}; 61use ra_db::{CrateId, Edition, FileId};
62use ra_prof::profile;
63use ra_syntax::ast; 62use ra_syntax::ast;
64use rustc_hash::FxHashMap; 63use rustc_hash::FxHashMap;
65use stdx::format_to; 64use stdx::format_to;
@@ -172,7 +171,7 @@ pub struct ModuleData {
172 171
173impl CrateDefMap { 172impl CrateDefMap {
174 pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { 173 pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
175 let _p = profile("crate_def_map_query").detail(|| { 174 let _p = profile::span("crate_def_map_query").detail(|| {
176 db.crate_graph()[krate] 175 db.crate_graph()[krate]
177 .display_name 176 .display_name
178 .as_ref() 177 .as_ref()
diff --git a/crates/ra_hir_expand/Cargo.toml b/crates/ra_hir_expand/Cargo.toml
index 808c36fd8..711a93c56 100644
--- a/crates/ra_hir_expand/Cargo.toml
+++ b/crates/ra_hir_expand/Cargo.toml
@@ -17,7 +17,7 @@ arena = { path = "../arena" }
17ra_db = { path = "../ra_db" } 17ra_db = { path = "../ra_db" }
18ra_syntax = { path = "../ra_syntax" } 18ra_syntax = { path = "../ra_syntax" }
19ra_parser = { path = "../ra_parser" } 19ra_parser = { path = "../ra_parser" }
20ra_prof = { path = "../ra_prof" } 20profile = { path = "../profile" }
21tt = { path = "../ra_tt", package = "ra_tt" } 21tt = { path = "../ra_tt", package = "ra_tt" }
22mbe = { path = "../ra_mbe", package = "ra_mbe" } 22mbe = { path = "../ra_mbe", package = "ra_mbe" }
23test_utils = { path = "../test_utils"} 23test_utils = { path = "../test_utils"}
diff --git a/crates/ra_hir_expand/src/db.rs b/crates/ra_hir_expand/src/db.rs
index f3b7cd492..f30528b3e 100644
--- a/crates/ra_hir_expand/src/db.rs
+++ b/crates/ra_hir_expand/src/db.rs
@@ -5,7 +5,6 @@ use std::sync::Arc;
5use mbe::{ExpandResult, MacroRules}; 5use mbe::{ExpandResult, MacroRules};
6use ra_db::{salsa, SourceDatabase}; 6use ra_db::{salsa, SourceDatabase};
7use ra_parser::FragmentKind; 7use ra_parser::FragmentKind;
8use ra_prof::profile;
9use ra_syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode}; 8use ra_syntax::{algo::diff, AstNode, GreenNode, Parse, SyntaxKind::*, SyntaxNode};
10 9
11use crate::{ 10use crate::{
@@ -278,7 +277,7 @@ pub fn parse_macro_with_arg(
278 macro_file: MacroFile, 277 macro_file: MacroFile,
279 arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>, 278 arg: Option<Arc<(tt::Subtree, mbe::TokenMap)>>,
280) -> Option<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)> { 279) -> Option<(Parse<SyntaxNode>, Arc<mbe::TokenMap>)> {
281 let _p = profile("parse_macro_query"); 280 let _p = profile::span("parse_macro_query");
282 281
283 let macro_call_id = macro_file.macro_call_id; 282 let macro_call_id = macro_file.macro_call_id;
284 let (tt, err) = if let Some(arg) = arg { 283 let (tt, err) = if let Some(arg) = arg {
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml
index fc68eaa8f..380d5e601 100644
--- a/crates/ra_hir_ty/Cargo.toml
+++ b/crates/ra_hir_ty/Cargo.toml
@@ -22,7 +22,7 @@ hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
22hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" } 22hir_expand = { path = "../ra_hir_expand", package = "ra_hir_expand" }
23arena = { path = "../arena" } 23arena = { path = "../arena" }
24ra_db = { path = "../ra_db" } 24ra_db = { path = "../ra_db" }
25ra_prof = { path = "../ra_prof" } 25profile = { path = "../profile" }
26ra_syntax = { path = "../ra_syntax" } 26ra_syntax = { path = "../ra_syntax" }
27test_utils = { path = "../test_utils" } 27test_utils = { path = "../test_utils" }
28 28
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index d396017bf..7a28673b1 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -8,7 +8,6 @@ use hir_def::{
8 TypeParamId, VariantId, 8 TypeParamId, VariantId,
9}; 9};
10use ra_db::{impl_intern_key, salsa, CrateId, Upcast}; 10use ra_db::{impl_intern_key, salsa, CrateId, Upcast};
11use ra_prof::profile;
12 11
13use crate::{ 12use crate::{
14 method_resolution::{InherentImpls, TraitImpls}, 13 method_resolution::{InherentImpls, TraitImpls},
@@ -123,7 +122,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
123} 122}
124 123
125fn infer_wait(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> { 124fn infer_wait(db: &impl HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
126 let _p = profile("infer:wait").detail(|| match def { 125 let _p = profile::span("infer:wait").detail(|| match def {
127 DefWithBodyId::FunctionId(it) => db.function_data(it).name.to_string(), 126 DefWithBodyId::FunctionId(it) => db.function_data(it).name.to_string(),
128 DefWithBodyId::StaticId(it) => { 127 DefWithBodyId::StaticId(it) => {
129 db.static_data(it).name.clone().unwrap_or_else(Name::missing).to_string() 128 db.static_data(it).name.clone().unwrap_or_else(Name::missing).to_string()
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 7ab7f79db..55c02c1fe 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -8,7 +8,6 @@ use std::any::Any;
8use hir_def::DefWithBodyId; 8use hir_def::DefWithBodyId;
9use hir_expand::diagnostics::{Diagnostic, DiagnosticSink}; 9use hir_expand::diagnostics::{Diagnostic, DiagnosticSink};
10use hir_expand::{name::Name, HirFileId, InFile}; 10use hir_expand::{name::Name, HirFileId, InFile};
11use ra_prof::profile;
12use ra_syntax::{ast, AstPtr, SyntaxNodePtr}; 11use ra_syntax::{ast, AstPtr, SyntaxNodePtr};
13use stdx::format_to; 12use stdx::format_to;
14 13
@@ -17,7 +16,7 @@ use crate::db::HirDatabase;
17pub use crate::diagnostics::expr::{record_literal_missing_fields, record_pattern_missing_fields}; 16pub use crate::diagnostics::expr::{record_literal_missing_fields, record_pattern_missing_fields};
18 17
19pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut DiagnosticSink<'_>) { 18pub fn validate_body(db: &dyn HirDatabase, owner: DefWithBodyId, sink: &mut DiagnosticSink<'_>) {
20 let _p = profile("validate_body"); 19 let _p = profile::span("validate_body");
21 let infer = db.infer(owner); 20 let infer = db.infer(owner);
22 infer.add_diagnostics(db, owner, sink); 21 infer.add_diagnostics(db, owner, sink);
23 let mut validator = expr::ExprValidator::new(owner, infer.clone(), sink); 22 let mut validator = expr::ExprValidator::new(owner, infer.clone(), sink);
diff --git a/crates/ra_hir_ty/src/infer.rs b/crates/ra_hir_ty/src/infer.rs
index e003690b3..784ae1c3c 100644
--- a/crates/ra_hir_ty/src/infer.rs
+++ b/crates/ra_hir_ty/src/infer.rs
@@ -31,7 +31,6 @@ use hir_def::{
31 TypeAliasId, VariantId, 31 TypeAliasId, VariantId,
32}; 32};
33use hir_expand::{diagnostics::DiagnosticSink, name::name}; 33use hir_expand::{diagnostics::DiagnosticSink, name::name};
34use ra_prof::profile;
35use ra_syntax::SmolStr; 34use ra_syntax::SmolStr;
36use rustc_hash::FxHashMap; 35use rustc_hash::FxHashMap;
37use stdx::impl_from; 36use stdx::impl_from;
@@ -64,7 +63,7 @@ mod coerce;
64 63
65/// The entry point of type inference. 64/// The entry point of type inference.
66pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> { 65pub(crate) fn infer_query(db: &dyn HirDatabase, def: DefWithBodyId) -> Arc<InferenceResult> {
67 let _p = profile("infer_query"); 66 let _p = profile::span("infer_query");
68 let resolver = def.resolver(db.upcast()); 67 let resolver = def.resolver(db.upcast());
69 let mut ctx = InferenceContext::new(db, def, resolver); 68 let mut ctx = InferenceContext::new(db, def, resolver);
70 69
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs
index fb4b30a13..3b3bee6a7 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/ra_hir_ty/src/method_resolution.rs
@@ -13,7 +13,6 @@ use hir_def::{
13}; 13};
14use hir_expand::name::Name; 14use hir_expand::name::Name;
15use ra_db::CrateId; 15use ra_db::CrateId;
16use ra_prof::profile;
17use rustc_hash::{FxHashMap, FxHashSet}; 16use rustc_hash::{FxHashMap, FxHashSet};
18 17
19use super::Substs; 18use super::Substs;
@@ -109,7 +108,7 @@ pub struct TraitImpls {
109 108
110impl TraitImpls { 109impl TraitImpls {
111 pub(crate) fn trait_impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> { 110 pub(crate) fn trait_impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> {
112 let _p = profile("trait_impls_in_crate_query"); 111 let _p = profile::span("trait_impls_in_crate_query");
113 let mut impls = Self { map: FxHashMap::default() }; 112 let mut impls = Self { map: FxHashMap::default() };
114 113
115 let crate_def_map = db.crate_def_map(krate); 114 let crate_def_map = db.crate_def_map(krate);
@@ -135,7 +134,7 @@ impl TraitImpls {
135 } 134 }
136 135
137 pub(crate) fn trait_impls_in_deps_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> { 136 pub(crate) fn trait_impls_in_deps_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> {
138 let _p = profile("trait_impls_in_deps_query"); 137 let _p = profile::span("trait_impls_in_deps_query");
139 let crate_graph = db.crate_graph(); 138 let crate_graph = db.crate_graph();
140 let mut res = Self { map: FxHashMap::default() }; 139 let mut res = Self { map: FxHashMap::default() };
141 140
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 3f6d2cf35..2576a9dfc 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -5,7 +5,6 @@ use chalk_ir::cast::Cast;
5use chalk_solve::Solver; 5use chalk_solve::Solver;
6use hir_def::{lang_item::LangItemTarget, TraitId}; 6use hir_def::{lang_item::LangItemTarget, TraitId};
7use ra_db::CrateId; 7use ra_db::CrateId;
8use ra_prof::profile;
9 8
10use crate::{db::HirDatabase, DebruijnIndex, Substs}; 9use crate::{db::HirDatabase, DebruijnIndex, Substs};
11 10
@@ -125,7 +124,7 @@ pub(crate) fn trait_solve_query(
125 krate: CrateId, 124 krate: CrateId,
126 goal: Canonical<InEnvironment<Obligation>>, 125 goal: Canonical<InEnvironment<Obligation>>,
127) -> Option<Solution> { 126) -> Option<Solution> {
128 let _p = profile("trait_solve_query").detail(|| match &goal.value.value { 127 let _p = profile::span("trait_solve_query").detail(|| match &goal.value.value {
129 Obligation::Trait(it) => db.trait_data(it.trait_).name.to_string(), 128 Obligation::Trait(it) => db.trait_data(it.trait_).name.to_string(),
130 Obligation::Projection(_) => "projection".to_string(), 129 Obligation::Projection(_) => "projection".to_string(),
131 }); 130 });
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 1c7065364..3b6af5c9a 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -410,7 +410,7 @@ pub(crate) fn impl_datum_query(
410 krate: CrateId, 410 krate: CrateId,
411 impl_id: ImplId, 411 impl_id: ImplId,
412) -> Arc<ImplDatum> { 412) -> Arc<ImplDatum> {
413 let _p = ra_prof::profile("impl_datum"); 413 let _p = profile::span("impl_datum");
414 debug!("impl_datum {:?}", impl_id); 414 debug!("impl_datum {:?}", impl_id);
415 let impl_: hir_def::ImplId = from_chalk(db, impl_id); 415 let impl_: hir_def::ImplId = from_chalk(db, impl_id);
416 impl_def_datum(db, krate, impl_id, impl_) 416 impl_def_datum(db, krate, impl_id, impl_)
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml
index f4181c4eb..bbc9ba4e7 100644
--- a/crates/ra_ide/Cargo.toml
+++ b/crates/ra_ide/Cargo.toml
@@ -27,7 +27,7 @@ ra_db = { path = "../ra_db" }
27ra_ide_db = { path = "../ra_ide_db" } 27ra_ide_db = { path = "../ra_ide_db" }
28ra_cfg = { path = "../ra_cfg" } 28ra_cfg = { path = "../ra_cfg" }
29ra_fmt = { path = "../ra_fmt" } 29ra_fmt = { path = "../ra_fmt" }
30ra_prof = { path = "../ra_prof" } 30profile = { path = "../profile" }
31test_utils = { path = "../test_utils" } 31test_utils = { path = "../test_utils" }
32ra_assists = { path = "../ra_assists" } 32ra_assists = { path = "../ra_assists" }
33ra_ssr = { path = "../ra_ssr" } 33ra_ssr = { path = "../ra_ssr" }
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 1046d7ab3..07bf133bd 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -10,7 +10,6 @@ use hir::{diagnostics::DiagnosticSinkBuilder, Semantics};
10use itertools::Itertools; 10use itertools::Itertools;
11use ra_db::SourceDatabase; 11use ra_db::SourceDatabase;
12use ra_ide_db::RootDatabase; 12use ra_ide_db::RootDatabase;
13use ra_prof::profile;
14use ra_syntax::{ 13use ra_syntax::{
15 ast::{self, AstNode}, 14 ast::{self, AstNode},
16 SyntaxNode, TextRange, T, 15 SyntaxNode, TextRange, T,
@@ -33,7 +32,7 @@ pub(crate) fn diagnostics(
33 file_id: FileId, 32 file_id: FileId,
34 enable_experimental: bool, 33 enable_experimental: bool,
35) -> Vec<Diagnostic> { 34) -> Vec<Diagnostic> {
36 let _p = profile("diagnostics"); 35 let _p = profile::span("diagnostics");
37 let sema = Semantics::new(db); 36 let sema = Semantics::new(db);
38 let parse = db.parse(file_id); 37 let parse = db.parse(file_id);
39 let mut res = Vec::new(); 38 let mut res = Vec::new();
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 1bacead63..920b04e8d 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -1,6 +1,5 @@
1use hir::{Adt, Callable, HirDisplay, Semantics, Type}; 1use hir::{Adt, Callable, HirDisplay, Semantics, Type};
2use ra_ide_db::RootDatabase; 2use ra_ide_db::RootDatabase;
3use ra_prof::profile;
4use ra_syntax::{ 3use ra_syntax::{
5 ast::{self, ArgListOwner, AstNode}, 4 ast::{self, ArgListOwner, AstNode},
6 match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T, 5 match_ast, Direction, NodeOrToken, SmolStr, SyntaxKind, TextRange, T,
@@ -64,7 +63,7 @@ pub(crate) fn inlay_hints(
64 file_id: FileId, 63 file_id: FileId,
65 config: &InlayHintsConfig, 64 config: &InlayHintsConfig,
66) -> Vec<InlayHint> { 65) -> Vec<InlayHint> {
67 let _p = profile("inlay_hints"); 66 let _p = profile::span("inlay_hints");
68 let sema = Semantics::new(db); 67 let sema = Semantics::new(db);
69 let file = sema.parse(file_id); 68 let file = sema.parse(file_id);
70 69
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 89fcb6f17..bfcf5d750 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -176,7 +176,7 @@ impl AnalysisHost {
176 self.db.collect_garbage(); 176 self.db.collect_garbage();
177 } 177 }
178 /// NB: this clears the database 178 /// NB: this clears the database
179 pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> { 179 pub fn per_query_memory_usage(&mut self) -> Vec<(String, profile::Bytes)> {
180 self.db.per_query_memory_usage() 180 self.db.per_query_memory_usage()
181 } 181 }
182 pub fn request_cancellation(&mut self) { 182 pub fn request_cancellation(&mut self) {
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs
index 453985de3..c4eea3a45 100644
--- a/crates/ra_ide/src/references.rs
+++ b/crates/ra_ide/src/references.rs
@@ -17,7 +17,6 @@ use ra_ide_db::{
17 search::SearchScope, 17 search::SearchScope,
18 RootDatabase, 18 RootDatabase,
19}; 19};
20use ra_prof::profile;
21use ra_syntax::{ 20use ra_syntax::{
22 algo::find_node_at_offset, 21 algo::find_node_at_offset,
23 ast::{self, NameOwner}, 22 ast::{self, NameOwner},
@@ -90,7 +89,7 @@ pub(crate) fn find_all_refs(
90 position: FilePosition, 89 position: FilePosition,
91 search_scope: Option<SearchScope>, 90 search_scope: Option<SearchScope>,
92) -> Option<RangeInfo<ReferenceSearchResult>> { 91) -> Option<RangeInfo<ReferenceSearchResult>> {
93 let _p = profile("find_all_refs"); 92 let _p = profile::span("find_all_refs");
94 let syntax = sema.parse(position.file_id).syntax().clone(); 93 let syntax = sema.parse(position.file_id).syntax().clone();
95 94
96 let (opt_name, search_kind) = if let Some(name) = 95 let (opt_name, search_kind) = if let Some(name) =
diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs
index 08e6f69cb..009bb662f 100644
--- a/crates/ra_ide/src/status.rs
+++ b/crates/ra_ide/src/status.rs
@@ -1,6 +1,7 @@
1use std::{fmt, iter::FromIterator, sync::Arc}; 1use std::{fmt, iter::FromIterator, sync::Arc};
2 2
3use hir::MacroFile; 3use hir::MacroFile;
4use profile::{memory_usage, Bytes};
4use ra_db::{ 5use ra_db::{
5 salsa::debug::{DebugQueryTable, TableEntry}, 6 salsa::debug::{DebugQueryTable, TableEntry},
6 FileTextQuery, SourceRootId, 7 FileTextQuery, SourceRootId,
@@ -9,7 +10,6 @@ use ra_ide_db::{
9 symbol_index::{LibrarySymbolsQuery, SymbolIndex}, 10 symbol_index::{LibrarySymbolsQuery, SymbolIndex},
10 RootDatabase, 11 RootDatabase,
11}; 12};
12use ra_prof::{memory_usage, Bytes};
13use ra_syntax::{ast, Parse, SyntaxNode}; 13use ra_syntax::{ast, Parse, SyntaxNode};
14use rustc_hash::FxHashMap; 14use rustc_hash::FxHashMap;
15 15
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index c10e15db8..ebdf05127 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -9,7 +9,6 @@ use ra_ide_db::{
9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, 9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
10 RootDatabase, 10 RootDatabase,
11}; 11};
12use ra_prof::profile;
13use ra_syntax::{ 12use ra_syntax::{
14 ast::{self, HasFormatSpecifier}, 13 ast::{self, HasFormatSpecifier},
15 AstNode, AstToken, Direction, NodeOrToken, SyntaxElement, 14 AstNode, AstToken, Direction, NodeOrToken, SyntaxElement,
@@ -46,7 +45,7 @@ pub(crate) fn highlight(
46 range_to_highlight: Option<TextRange>, 45 range_to_highlight: Option<TextRange>,
47 syntactic_name_ref_highlighting: bool, 46 syntactic_name_ref_highlighting: bool,
48) -> Vec<HighlightedRange> { 47) -> Vec<HighlightedRange> {
49 let _p = profile("highlight"); 48 let _p = profile::span("highlight");
50 let sema = Semantics::new(db); 49 let sema = Semantics::new(db);
51 50
52 // Determine the root based on the given range. 51 // Determine the root based on the given range.
diff --git a/crates/ra_ide_db/Cargo.toml b/crates/ra_ide_db/Cargo.toml
index 2716a38cc..92b8ef82a 100644
--- a/crates/ra_ide_db/Cargo.toml
+++ b/crates/ra_ide_db/Cargo.toml
@@ -24,7 +24,7 @@ stdx = { path = "../stdx" }
24ra_syntax = { path = "../ra_syntax" } 24ra_syntax = { path = "../ra_syntax" }
25ra_text_edit = { path = "../ra_text_edit" } 25ra_text_edit = { path = "../ra_text_edit" }
26ra_db = { path = "../ra_db" } 26ra_db = { path = "../ra_db" }
27ra_prof = { path = "../ra_prof" } 27profile = { path = "../profile" }
28test_utils = { path = "../test_utils" } 28test_utils = { path = "../test_utils" }
29 29
30# ra_ide should depend only on the top-level `hir` package. if you need 30# ra_ide should depend only on the top-level `hir` package. if you need
diff --git a/crates/ra_ide_db/src/change.rs b/crates/ra_ide_db/src/change.rs
index b13df8b85..7a4e04ca9 100644
--- a/crates/ra_ide_db/src/change.rs
+++ b/crates/ra_ide_db/src/change.rs
@@ -3,11 +3,11 @@
3 3
4use std::{fmt, sync::Arc, time}; 4use std::{fmt, sync::Arc, time};
5 5
6use profile::{memory_usage, Bytes};
6use ra_db::{ 7use ra_db::{
7 salsa::{Database, Durability, SweepStrategy}, 8 salsa::{Database, Durability, SweepStrategy},
8 CrateGraph, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId, 9 CrateGraph, FileId, SourceDatabase, SourceDatabaseExt, SourceRoot, SourceRootId,
9}; 10};
10use ra_prof::{memory_usage, profile, Bytes};
11use rustc_hash::FxHashSet; 11use rustc_hash::FxHashSet;
12 12
13use crate::{symbol_index::SymbolsDatabase, RootDatabase}; 13use crate::{symbol_index::SymbolsDatabase, RootDatabase};
@@ -85,12 +85,12 @@ const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100);
85 85
86impl RootDatabase { 86impl RootDatabase {
87 pub fn request_cancellation(&mut self) { 87 pub fn request_cancellation(&mut self) {
88 let _p = profile("RootDatabase::request_cancellation"); 88 let _p = profile::span("RootDatabase::request_cancellation");
89 self.salsa_runtime_mut().synthetic_write(Durability::LOW); 89 self.salsa_runtime_mut().synthetic_write(Durability::LOW);
90 } 90 }
91 91
92 pub fn apply_change(&mut self, change: AnalysisChange) { 92 pub fn apply_change(&mut self, change: AnalysisChange) {
93 let _p = profile("RootDatabase::apply_change"); 93 let _p = profile::span("RootDatabase::apply_change");
94 self.request_cancellation(); 94 self.request_cancellation();
95 log::info!("apply_change {:?}", change); 95 log::info!("apply_change {:?}", change);
96 if let Some(roots) = change.roots { 96 if let Some(roots) = change.roots {
@@ -141,7 +141,7 @@ impl RootDatabase {
141 return; 141 return;
142 } 142 }
143 143
144 let _p = profile("RootDatabase::collect_garbage"); 144 let _p = profile::span("RootDatabase::collect_garbage");
145 self.last_gc = crate::wasm_shims::Instant::now(); 145 self.last_gc = crate::wasm_shims::Instant::now();
146 146
147 let sweep = SweepStrategy::default().discard_values().sweep_all_revisions(); 147 let sweep = SweepStrategy::default().discard_values().sweep_all_revisions();
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index 9bb95277d..d46d1fe71 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -9,7 +9,6 @@ use hir::{
9 db::HirDatabase, Crate, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, 9 db::HirDatabase, Crate, Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef,
10 Name, PathResolution, Semantics, TypeParam, Visibility, 10 Name, PathResolution, Semantics, TypeParam, Visibility,
11}; 11};
12use ra_prof::profile;
13use ra_syntax::{ 12use ra_syntax::{
14 ast::{self, AstNode}, 13 ast::{self, AstNode},
15 match_ast, SyntaxNode, 14 match_ast, SyntaxNode,
@@ -110,7 +109,7 @@ impl NameClass {
110} 109}
111 110
112pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> { 111pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> {
113 let _p = profile("classify_name"); 112 let _p = profile::span("classify_name");
114 113
115 let parent = name.syntax().parent()?; 114 let parent = name.syntax().parent()?;
116 115
@@ -249,7 +248,7 @@ pub fn classify_name_ref(
249 sema: &Semantics<RootDatabase>, 248 sema: &Semantics<RootDatabase>,
250 name_ref: &ast::NameRef, 249 name_ref: &ast::NameRef,
251) -> Option<NameRefClass> { 250) -> Option<NameRefClass> {
252 let _p = profile("classify_name_ref"); 251 let _p = profile::span("classify_name_ref");
253 252
254 let parent = name_ref.syntax().parent()?; 253 let parent = name_ref.syntax().parent()?;
255 254
diff --git a/crates/ra_ide_db/src/imports_locator.rs b/crates/ra_ide_db/src/imports_locator.rs
index 9e040973b..d510ce3b7 100644
--- a/crates/ra_ide_db/src/imports_locator.rs
+++ b/crates/ra_ide_db/src/imports_locator.rs
@@ -2,7 +2,6 @@
2//! Later, this should be moved away to a separate crate that is accessible from the ra_assists module. 2//! Later, this should be moved away to a separate crate that is accessible from the ra_assists module.
3 3
4use hir::{Crate, MacroDef, ModuleDef, Semantics}; 4use hir::{Crate, MacroDef, ModuleDef, Semantics};
5use ra_prof::profile;
6use ra_syntax::{ast, AstNode, SyntaxKind::NAME}; 5use ra_syntax::{ast, AstNode, SyntaxKind::NAME};
7 6
8use crate::{ 7use crate::{
@@ -18,7 +17,7 @@ pub fn find_imports<'a>(
18 krate: Crate, 17 krate: Crate,
19 name_to_import: &str, 18 name_to_import: &str,
20) -> Vec<Either<ModuleDef, MacroDef>> { 19) -> Vec<Either<ModuleDef, MacroDef>> {
21 let _p = profile("search_for_imports"); 20 let _p = profile::span("search_for_imports");
22 let db = sema.db; 21 let db = sema.db;
23 22
24 // Query dependencies first. 23 // Query dependencies first.
@@ -51,7 +50,7 @@ fn get_name_definition<'a>(
51 sema: &Semantics<'a, RootDatabase>, 50 sema: &Semantics<'a, RootDatabase>,
52 import_candidate: &FileSymbol, 51 import_candidate: &FileSymbol,
53) -> Option<Definition> { 52) -> Option<Definition> {
54 let _p = profile("get_name_definition"); 53 let _p = profile::span("get_name_definition");
55 let file_id = import_candidate.file_id; 54 let file_id = import_candidate.file_id;
56 55
57 let candidate_node = import_candidate.ptr.to_node(sema.parse(file_id).syntax()); 56 let candidate_node = import_candidate.ptr.to_node(sema.parse(file_id).syntax());
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index 0b862b449..d90b830d0 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ra_ide_db/src/search.rs
@@ -9,7 +9,6 @@ use std::{convert::TryInto, mem};
9use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility}; 9use hir::{DefWithBody, HasSource, Module, ModuleSource, Semantics, Visibility};
10use once_cell::unsync::Lazy; 10use once_cell::unsync::Lazy;
11use ra_db::{FileId, FileRange, SourceDatabaseExt}; 11use ra_db::{FileId, FileRange, SourceDatabaseExt};
12use ra_prof::profile;
13use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize}; 12use ra_syntax::{ast, match_ast, AstNode, TextRange, TextSize};
14use rustc_hash::FxHashMap; 13use rustc_hash::FxHashMap;
15 14
@@ -107,7 +106,7 @@ impl IntoIterator for SearchScope {
107 106
108impl Definition { 107impl Definition {
109 fn search_scope(&self, db: &RootDatabase) -> SearchScope { 108 fn search_scope(&self, db: &RootDatabase) -> SearchScope {
110 let _p = profile("search_scope"); 109 let _p = profile::span("search_scope");
111 let module = match self.module(db) { 110 let module = match self.module(db) {
112 Some(it) => it, 111 Some(it) => it,
113 None => return SearchScope::empty(), 112 None => return SearchScope::empty(),
@@ -187,7 +186,7 @@ impl Definition {
187 sema: &Semantics<RootDatabase>, 186 sema: &Semantics<RootDatabase>,
188 search_scope: Option<SearchScope>, 187 search_scope: Option<SearchScope>,
189 ) -> Vec<Reference> { 188 ) -> Vec<Reference> {
190 let _p = profile("Definition::find_usages"); 189 let _p = profile::span("Definition::find_usages");
191 190
192 let search_scope = { 191 let search_scope = {
193 let base = self.search_scope(sema.db); 192 let base = self.search_scope(sema.db);
diff --git a/crates/ra_ide_db/src/symbol_index.rs b/crates/ra_ide_db/src/symbol_index.rs
index 35a2c5be3..6ca8bb516 100644
--- a/crates/ra_ide_db/src/symbol_index.rs
+++ b/crates/ra_ide_db/src/symbol_index.rs
@@ -34,7 +34,6 @@ use ra_db::{
34 salsa::{self, ParallelDatabase}, 34 salsa::{self, ParallelDatabase},
35 CrateId, FileId, SourceDatabaseExt, SourceRootId, 35 CrateId, FileId, SourceDatabaseExt, SourceRootId,
36}; 36};
37use ra_prof::profile;
38use ra_syntax::{ 37use ra_syntax::{
39 ast::{self, NameOwner}, 38 ast::{self, NameOwner},
40 match_ast, AstNode, Parse, SmolStr, SourceFile, 39 match_ast, AstNode, Parse, SmolStr, SourceFile,
@@ -101,7 +100,7 @@ pub trait SymbolsDatabase: hir::db::HirDatabase + SourceDatabaseExt {
101} 100}
102 101
103fn library_symbols(db: &dyn SymbolsDatabase) -> Arc<FxHashMap<SourceRootId, SymbolIndex>> { 102fn library_symbols(db: &dyn SymbolsDatabase) -> Arc<FxHashMap<SourceRootId, SymbolIndex>> {
104 let _p = profile("library_symbols"); 103 let _p = profile::span("library_symbols");
105 104
106 let roots = db.library_roots(); 105 let roots = db.library_roots();
107 let res = roots 106 let res = roots
@@ -162,7 +161,7 @@ impl<DB: ParallelDatabase> Clone for Snap<salsa::Snapshot<DB>> {
162// | VS Code | kbd:[Ctrl+T] 161// | VS Code | kbd:[Ctrl+T]
163// |=== 162// |===
164pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> { 163pub fn world_symbols(db: &RootDatabase, query: Query) -> Vec<FileSymbol> {
165 let _p = ra_prof::profile("world_symbols").detail(|| query.query.clone()); 164 let _p = profile::span("world_symbols").detail(|| query.query.clone());
166 165
167 let tmp1; 166 let tmp1;
168 let tmp2; 167 let tmp2;
diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml
index 02c1371ac..6cbf43bb2 100644
--- a/crates/rust-analyzer/Cargo.toml
+++ b/crates/rust-analyzer/Cargo.toml
@@ -36,7 +36,7 @@ stdx = { path = "../stdx" }
36lsp-server = "0.3.3" 36lsp-server = "0.3.3"
37flycheck = { path = "../flycheck" } 37flycheck = { path = "../flycheck" }
38ra_ide = { path = "../ra_ide" } 38ra_ide = { path = "../ra_ide" }
39ra_prof = { path = "../ra_prof" } 39profile = { path = "../profile" }
40ra_project_model = { path = "../ra_project_model" } 40ra_project_model = { path = "../ra_project_model" }
41ra_syntax = { path = "../ra_syntax" } 41ra_syntax = { path = "../ra_syntax" }
42ra_text_edit = { path = "../ra_text_edit" } 42ra_text_edit = { path = "../ra_text_edit" }
diff --git a/crates/rust-analyzer/src/bin/main.rs b/crates/rust-analyzer/src/bin/main.rs
index fc7f8b01d..9622d71c0 100644
--- a/crates/rust-analyzer/src/bin/main.rs
+++ b/crates/rust-analyzer/src/bin/main.rs
@@ -55,7 +55,7 @@ fn try_main() -> Result<()> {
55fn setup_logging() -> Result<()> { 55fn setup_logging() -> Result<()> {
56 std::env::set_var("RUST_BACKTRACE", "short"); 56 std::env::set_var("RUST_BACKTRACE", "short");
57 env_logger::try_init_from_env("RA_LOG")?; 57 env_logger::try_init_from_env("RA_LOG")?;
58 ra_prof::init(); 58 profile::init();
59 Ok(()) 59 Ok(())
60} 60}
61 61
diff --git a/crates/rust-analyzer/src/cli.rs b/crates/rust-analyzer/src/cli.rs
index 1034d11bd..46d70fcb2 100644
--- a/crates/rust-analyzer/src/cli.rs
+++ b/crates/rust-analyzer/src/cli.rs
@@ -11,7 +11,6 @@ use std::io::Read;
11 11
12use anyhow::Result; 12use anyhow::Result;
13use ra_ide::Analysis; 13use ra_ide::Analysis;
14use ra_prof::profile;
15use ra_syntax::{AstNode, SourceFile}; 14use ra_syntax::{AstNode, SourceFile};
16 15
17pub use analysis_bench::{BenchCmd, BenchWhat, Position}; 16pub use analysis_bench::{BenchCmd, BenchWhat, Position};
@@ -38,7 +37,7 @@ impl Verbosity {
38} 37}
39 38
40pub fn parse(no_dump: bool) -> Result<()> { 39pub fn parse(no_dump: bool) -> Result<()> {
41 let _p = profile("parsing"); 40 let _p = profile::span("parsing");
42 let file = file()?; 41 let file = file()?;
43 if !no_dump { 42 if !no_dump {
44 println!("{:#?}", file.syntax()); 43 println!("{:#?}", file.syntax());
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs
index c54ee5f4d..bc5f77e1a 100644
--- a/crates/rust-analyzer/src/cli/analysis_bench.rs
+++ b/crates/rust-analyzer/src/cli/analysis_bench.rs
@@ -52,7 +52,7 @@ impl FromStr for Position {
52 52
53impl BenchCmd { 53impl BenchCmd {
54 pub fn run(self, verbosity: Verbosity) -> Result<()> { 54 pub fn run(self, verbosity: Verbosity) -> Result<()> {
55 ra_prof::init(); 55 profile::init();
56 56
57 let start = Instant::now(); 57 let start = Instant::now();
58 eprint!("loading: "); 58 eprint!("loading: ");
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 0d386841e..a30c1ec79 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -29,7 +29,7 @@ use crate::{
29 }, 29 },
30 print_memory_usage, 30 print_memory_usage,
31}; 31};
32use ra_prof::StopWatch; 32use profile::StopWatch;
33 33
34/// Need to wrap Snapshot to provide `Clone` impl for `map_with` 34/// Need to wrap Snapshot to provide `Clone` impl for `map_with`
35struct Snap<DB>(DB); 35struct Snap<DB>(DB);
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index 658a50d15..8c115c8a6 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -27,7 +27,6 @@ use crate::{
27 to_proto::url_from_abs_path, 27 to_proto::url_from_abs_path,
28 Result, 28 Result,
29}; 29};
30use ra_prof::profile;
31 30
32#[derive(Eq, PartialEq, Copy, Clone)] 31#[derive(Eq, PartialEq, Copy, Clone)]
33pub(crate) enum Status { 32pub(crate) enum Status {
@@ -135,7 +134,7 @@ impl GlobalState {
135 } 134 }
136 135
137 pub(crate) fn process_changes(&mut self) -> bool { 136 pub(crate) fn process_changes(&mut self) -> bool {
138 let _p = profile("GlobalState::process_changes"); 137 let _p = profile::span("GlobalState::process_changes");
139 let mut fs_changes = Vec::new(); 138 let mut fs_changes = Vec::new();
140 let mut has_fs_changes = false; 139 let mut has_fs_changes = false;
141 140
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 785dd2a26..d9b75eed4 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -22,7 +22,6 @@ use ra_ide::{
22 FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query, 22 FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query,
23 RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit, 23 RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit,
24}; 24};
25use ra_prof::profile;
26use ra_project_model::TargetKind; 25use ra_project_model::TargetKind;
27use ra_syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize}; 26use ra_syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize};
28use serde::{Deserialize, Serialize}; 27use serde::{Deserialize, Serialize};
@@ -39,7 +38,7 @@ use crate::{
39}; 38};
40 39
41pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> { 40pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> {
42 let _p = profile("handle_analyzer_status"); 41 let _p = profile::span("handle_analyzer_status");
43 42
44 let mut buf = String::new(); 43 let mut buf = String::new();
45 if snap.workspaces.is_empty() { 44 if snap.workspaces.is_empty() {
@@ -64,7 +63,7 @@ pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result
64} 63}
65 64
66pub(crate) fn handle_memory_usage(state: &mut GlobalState, _: ()) -> Result<String> { 65pub(crate) fn handle_memory_usage(state: &mut GlobalState, _: ()) -> Result<String> {
67 let _p = profile("handle_memory_usage"); 66 let _p = profile::span("handle_memory_usage");
68 let mem = state.analysis_host.per_query_memory_usage(); 67 let mem = state.analysis_host.per_query_memory_usage();
69 68
70 let mut out = String::new(); 69 let mut out = String::new();
@@ -78,7 +77,7 @@ pub(crate) fn handle_syntax_tree(
78 snap: GlobalStateSnapshot, 77 snap: GlobalStateSnapshot,
79 params: lsp_ext::SyntaxTreeParams, 78 params: lsp_ext::SyntaxTreeParams,
80) -> Result<String> { 79) -> Result<String> {
81 let _p = profile("handle_syntax_tree"); 80 let _p = profile::span("handle_syntax_tree");
82 let id = from_proto::file_id(&snap, &params.text_document.uri)?; 81 let id = from_proto::file_id(&snap, &params.text_document.uri)?;
83 let line_index = snap.analysis.file_line_index(id)?; 82 let line_index = snap.analysis.file_line_index(id)?;
84 let text_range = params.range.map(|r| from_proto::text_range(&line_index, r)); 83 let text_range = params.range.map(|r| from_proto::text_range(&line_index, r));
@@ -90,7 +89,7 @@ pub(crate) fn handle_expand_macro(
90 snap: GlobalStateSnapshot, 89 snap: GlobalStateSnapshot,
91 params: lsp_ext::ExpandMacroParams, 90 params: lsp_ext::ExpandMacroParams,
92) -> Result<Option<lsp_ext::ExpandedMacro>> { 91) -> Result<Option<lsp_ext::ExpandedMacro>> {
93 let _p = profile("handle_expand_macro"); 92 let _p = profile::span("handle_expand_macro");
94 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 93 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
95 let line_index = snap.analysis.file_line_index(file_id)?; 94 let line_index = snap.analysis.file_line_index(file_id)?;
96 let offset = from_proto::offset(&line_index, params.position); 95 let offset = from_proto::offset(&line_index, params.position);
@@ -103,7 +102,7 @@ pub(crate) fn handle_selection_range(
103 snap: GlobalStateSnapshot, 102 snap: GlobalStateSnapshot,
104 params: lsp_types::SelectionRangeParams, 103 params: lsp_types::SelectionRangeParams,
105) -> Result<Option<Vec<lsp_types::SelectionRange>>> { 104) -> Result<Option<Vec<lsp_types::SelectionRange>>> {
106 let _p = profile("handle_selection_range"); 105 let _p = profile::span("handle_selection_range");
107 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 106 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
108 let line_index = snap.analysis.file_line_index(file_id)?; 107 let line_index = snap.analysis.file_line_index(file_id)?;
109 let res: Result<Vec<lsp_types::SelectionRange>> = params 108 let res: Result<Vec<lsp_types::SelectionRange>> = params
@@ -146,7 +145,7 @@ pub(crate) fn handle_matching_brace(
146 snap: GlobalStateSnapshot, 145 snap: GlobalStateSnapshot,
147 params: lsp_ext::MatchingBraceParams, 146 params: lsp_ext::MatchingBraceParams,
148) -> Result<Vec<Position>> { 147) -> Result<Vec<Position>> {
149 let _p = profile("handle_matching_brace"); 148 let _p = profile::span("handle_matching_brace");
150 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 149 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
151 let line_index = snap.analysis.file_line_index(file_id)?; 150 let line_index = snap.analysis.file_line_index(file_id)?;
152 let res = params 151 let res = params
@@ -168,7 +167,7 @@ pub(crate) fn handle_join_lines(
168 snap: GlobalStateSnapshot, 167 snap: GlobalStateSnapshot,
169 params: lsp_ext::JoinLinesParams, 168 params: lsp_ext::JoinLinesParams,
170) -> Result<Vec<lsp_types::TextEdit>> { 169) -> Result<Vec<lsp_types::TextEdit>> {
171 let _p = profile("handle_join_lines"); 170 let _p = profile::span("handle_join_lines");
172 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 171 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
173 let line_index = snap.analysis.file_line_index(file_id)?; 172 let line_index = snap.analysis.file_line_index(file_id)?;
174 let line_endings = snap.file_line_endings(file_id); 173 let line_endings = snap.file_line_endings(file_id);
@@ -191,7 +190,7 @@ pub(crate) fn handle_on_enter(
191 snap: GlobalStateSnapshot, 190 snap: GlobalStateSnapshot,
192 params: lsp_types::TextDocumentPositionParams, 191 params: lsp_types::TextDocumentPositionParams,
193) -> Result<Option<Vec<lsp_ext::SnippetTextEdit>>> { 192) -> Result<Option<Vec<lsp_ext::SnippetTextEdit>>> {
194 let _p = profile("handle_on_enter"); 193 let _p = profile::span("handle_on_enter");
195 let position = from_proto::file_position(&snap, params)?; 194 let position = from_proto::file_position(&snap, params)?;
196 let edit = match snap.analysis.on_enter(position)? { 195 let edit = match snap.analysis.on_enter(position)? {
197 None => return Ok(None), 196 None => return Ok(None),
@@ -208,7 +207,7 @@ pub(crate) fn handle_on_type_formatting(
208 snap: GlobalStateSnapshot, 207 snap: GlobalStateSnapshot,
209 params: lsp_types::DocumentOnTypeFormattingParams, 208 params: lsp_types::DocumentOnTypeFormattingParams,
210) -> Result<Option<Vec<lsp_types::TextEdit>>> { 209) -> Result<Option<Vec<lsp_types::TextEdit>>> {
211 let _p = profile("handle_on_type_formatting"); 210 let _p = profile::span("handle_on_type_formatting");
212 let mut position = from_proto::file_position(&snap, params.text_document_position)?; 211 let mut position = from_proto::file_position(&snap, params.text_document_position)?;
213 let line_index = snap.analysis.file_line_index(position.file_id)?; 212 let line_index = snap.analysis.file_line_index(position.file_id)?;
214 let line_endings = snap.file_line_endings(position.file_id); 213 let line_endings = snap.file_line_endings(position.file_id);
@@ -247,7 +246,7 @@ pub(crate) fn handle_document_symbol(
247 snap: GlobalStateSnapshot, 246 snap: GlobalStateSnapshot,
248 params: lsp_types::DocumentSymbolParams, 247 params: lsp_types::DocumentSymbolParams,
249) -> Result<Option<lsp_types::DocumentSymbolResponse>> { 248) -> Result<Option<lsp_types::DocumentSymbolResponse>> {
250 let _p = profile("handle_document_symbol"); 249 let _p = profile::span("handle_document_symbol");
251 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 250 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
252 let line_index = snap.analysis.file_line_index(file_id)?; 251 let line_index = snap.analysis.file_line_index(file_id)?;
253 252
@@ -332,7 +331,7 @@ pub(crate) fn handle_workspace_symbol(
332 snap: GlobalStateSnapshot, 331 snap: GlobalStateSnapshot,
333 params: lsp_types::WorkspaceSymbolParams, 332 params: lsp_types::WorkspaceSymbolParams,
334) -> Result<Option<Vec<SymbolInformation>>> { 333) -> Result<Option<Vec<SymbolInformation>>> {
335 let _p = profile("handle_workspace_symbol"); 334 let _p = profile::span("handle_workspace_symbol");
336 let all_symbols = params.query.contains('#'); 335 let all_symbols = params.query.contains('#');
337 let libs = params.query.contains('*'); 336 let libs = params.query.contains('*');
338 let query = { 337 let query = {
@@ -380,7 +379,7 @@ pub(crate) fn handle_goto_definition(
380 snap: GlobalStateSnapshot, 379 snap: GlobalStateSnapshot,
381 params: lsp_types::GotoDefinitionParams, 380 params: lsp_types::GotoDefinitionParams,
382) -> Result<Option<lsp_types::GotoDefinitionResponse>> { 381) -> Result<Option<lsp_types::GotoDefinitionResponse>> {
383 let _p = profile("handle_goto_definition"); 382 let _p = profile::span("handle_goto_definition");
384 let position = from_proto::file_position(&snap, params.text_document_position_params)?; 383 let position = from_proto::file_position(&snap, params.text_document_position_params)?;
385 let nav_info = match snap.analysis.goto_definition(position)? { 384 let nav_info = match snap.analysis.goto_definition(position)? {
386 None => return Ok(None), 385 None => return Ok(None),
@@ -395,7 +394,7 @@ pub(crate) fn handle_goto_implementation(
395 snap: GlobalStateSnapshot, 394 snap: GlobalStateSnapshot,
396 params: lsp_types::request::GotoImplementationParams, 395 params: lsp_types::request::GotoImplementationParams,
397) -> Result<Option<lsp_types::request::GotoImplementationResponse>> { 396) -> Result<Option<lsp_types::request::GotoImplementationResponse>> {
398 let _p = profile("handle_goto_implementation"); 397 let _p = profile::span("handle_goto_implementation");
399 let position = from_proto::file_position(&snap, params.text_document_position_params)?; 398 let position = from_proto::file_position(&snap, params.text_document_position_params)?;
400 let nav_info = match snap.analysis.goto_implementation(position)? { 399 let nav_info = match snap.analysis.goto_implementation(position)? {
401 None => return Ok(None), 400 None => return Ok(None),
@@ -410,7 +409,7 @@ pub(crate) fn handle_goto_type_definition(
410 snap: GlobalStateSnapshot, 409 snap: GlobalStateSnapshot,
411 params: lsp_types::request::GotoTypeDefinitionParams, 410 params: lsp_types::request::GotoTypeDefinitionParams,
412) -> Result<Option<lsp_types::request::GotoTypeDefinitionResponse>> { 411) -> Result<Option<lsp_types::request::GotoTypeDefinitionResponse>> {
413 let _p = profile("handle_goto_type_definition"); 412 let _p = profile::span("handle_goto_type_definition");
414 let position = from_proto::file_position(&snap, params.text_document_position_params)?; 413 let position = from_proto::file_position(&snap, params.text_document_position_params)?;
415 let nav_info = match snap.analysis.goto_type_definition(position)? { 414 let nav_info = match snap.analysis.goto_type_definition(position)? {
416 None => return Ok(None), 415 None => return Ok(None),
@@ -425,7 +424,7 @@ pub(crate) fn handle_parent_module(
425 snap: GlobalStateSnapshot, 424 snap: GlobalStateSnapshot,
426 params: lsp_types::TextDocumentPositionParams, 425 params: lsp_types::TextDocumentPositionParams,
427) -> Result<Option<lsp_types::GotoDefinitionResponse>> { 426) -> Result<Option<lsp_types::GotoDefinitionResponse>> {
428 let _p = profile("handle_parent_module"); 427 let _p = profile::span("handle_parent_module");
429 let position = from_proto::file_position(&snap, params)?; 428 let position = from_proto::file_position(&snap, params)?;
430 let navs = snap.analysis.parent_module(position)?; 429 let navs = snap.analysis.parent_module(position)?;
431 let res = to_proto::goto_definition_response(&snap, None, navs)?; 430 let res = to_proto::goto_definition_response(&snap, None, navs)?;
@@ -436,7 +435,7 @@ pub(crate) fn handle_runnables(
436 snap: GlobalStateSnapshot, 435 snap: GlobalStateSnapshot,
437 params: lsp_ext::RunnablesParams, 436 params: lsp_ext::RunnablesParams,
438) -> Result<Vec<lsp_ext::Runnable>> { 437) -> Result<Vec<lsp_ext::Runnable>> {
439 let _p = profile("handle_runnables"); 438 let _p = profile::span("handle_runnables");
440 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 439 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
441 let line_index = snap.analysis.file_line_index(file_id)?; 440 let line_index = snap.analysis.file_line_index(file_id)?;
442 let offset = params.position.map(|it| from_proto::offset(&line_index, it)); 441 let offset = params.position.map(|it| from_proto::offset(&line_index, it));
@@ -513,7 +512,7 @@ pub(crate) fn handle_completion(
513 snap: GlobalStateSnapshot, 512 snap: GlobalStateSnapshot,
514 params: lsp_types::CompletionParams, 513 params: lsp_types::CompletionParams,
515) -> Result<Option<lsp_types::CompletionResponse>> { 514) -> Result<Option<lsp_types::CompletionResponse>> {
516 let _p = profile("handle_completion"); 515 let _p = profile::span("handle_completion");
517 let position = from_proto::file_position(&snap, params.text_document_position)?; 516 let position = from_proto::file_position(&snap, params.text_document_position)?;
518 let completion_triggered_after_single_colon = { 517 let completion_triggered_after_single_colon = {
519 let mut res = false; 518 let mut res = false;
@@ -555,7 +554,7 @@ pub(crate) fn handle_folding_range(
555 snap: GlobalStateSnapshot, 554 snap: GlobalStateSnapshot,
556 params: FoldingRangeParams, 555 params: FoldingRangeParams,
557) -> Result<Option<Vec<FoldingRange>>> { 556) -> Result<Option<Vec<FoldingRange>>> {
558 let _p = profile("handle_folding_range"); 557 let _p = profile::span("handle_folding_range");
559 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 558 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
560 let folds = snap.analysis.folding_ranges(file_id)?; 559 let folds = snap.analysis.folding_ranges(file_id)?;
561 let text = snap.analysis.file_text(file_id)?; 560 let text = snap.analysis.file_text(file_id)?;
@@ -572,7 +571,7 @@ pub(crate) fn handle_signature_help(
572 snap: GlobalStateSnapshot, 571 snap: GlobalStateSnapshot,
573 params: lsp_types::SignatureHelpParams, 572 params: lsp_types::SignatureHelpParams,
574) -> Result<Option<lsp_types::SignatureHelp>> { 573) -> Result<Option<lsp_types::SignatureHelp>> {
575 let _p = profile("handle_signature_help"); 574 let _p = profile::span("handle_signature_help");
576 let position = from_proto::file_position(&snap, params.text_document_position_params)?; 575 let position = from_proto::file_position(&snap, params.text_document_position_params)?;
577 let call_info = match snap.analysis.call_info(position)? { 576 let call_info = match snap.analysis.call_info(position)? {
578 Some(it) => it, 577 Some(it) => it,
@@ -591,7 +590,7 @@ pub(crate) fn handle_hover(
591 snap: GlobalStateSnapshot, 590 snap: GlobalStateSnapshot,
592 params: lsp_types::HoverParams, 591 params: lsp_types::HoverParams,
593) -> Result<Option<lsp_ext::Hover>> { 592) -> Result<Option<lsp_ext::Hover>> {
594 let _p = profile("handle_hover"); 593 let _p = profile::span("handle_hover");
595 let position = from_proto::file_position(&snap, params.text_document_position_params)?; 594 let position = from_proto::file_position(&snap, params.text_document_position_params)?;
596 let info = match snap.analysis.hover(position)? { 595 let info = match snap.analysis.hover(position)? {
597 None => return Ok(None), 596 None => return Ok(None),
@@ -614,7 +613,7 @@ pub(crate) fn handle_prepare_rename(
614 snap: GlobalStateSnapshot, 613 snap: GlobalStateSnapshot,
615 params: lsp_types::TextDocumentPositionParams, 614 params: lsp_types::TextDocumentPositionParams,
616) -> Result<Option<PrepareRenameResponse>> { 615) -> Result<Option<PrepareRenameResponse>> {
617 let _p = profile("handle_prepare_rename"); 616 let _p = profile::span("handle_prepare_rename");
618 let position = from_proto::file_position(&snap, params)?; 617 let position = from_proto::file_position(&snap, params)?;
619 618
620 let optional_change = snap.analysis.rename(position, "dummy")?; 619 let optional_change = snap.analysis.rename(position, "dummy")?;
@@ -632,7 +631,7 @@ pub(crate) fn handle_rename(
632 snap: GlobalStateSnapshot, 631 snap: GlobalStateSnapshot,
633 params: RenameParams, 632 params: RenameParams,
634) -> Result<Option<WorkspaceEdit>> { 633) -> Result<Option<WorkspaceEdit>> {
635 let _p = profile("handle_rename"); 634 let _p = profile::span("handle_rename");
636 let position = from_proto::file_position(&snap, params.text_document_position)?; 635 let position = from_proto::file_position(&snap, params.text_document_position)?;
637 636
638 if params.new_name.is_empty() { 637 if params.new_name.is_empty() {
@@ -656,7 +655,7 @@ pub(crate) fn handle_references(
656 snap: GlobalStateSnapshot, 655 snap: GlobalStateSnapshot,
657 params: lsp_types::ReferenceParams, 656 params: lsp_types::ReferenceParams,
658) -> Result<Option<Vec<Location>>> { 657) -> Result<Option<Vec<Location>>> {
659 let _p = profile("handle_references"); 658 let _p = profile::span("handle_references");
660 let position = from_proto::file_position(&snap, params.text_document_position)?; 659 let position = from_proto::file_position(&snap, params.text_document_position)?;
661 660
662 let refs = match snap.analysis.find_all_refs(position, None)? { 661 let refs = match snap.analysis.find_all_refs(position, None)? {
@@ -683,7 +682,7 @@ pub(crate) fn handle_formatting(
683 snap: GlobalStateSnapshot, 682 snap: GlobalStateSnapshot,
684 params: DocumentFormattingParams, 683 params: DocumentFormattingParams,
685) -> Result<Option<Vec<lsp_types::TextEdit>>> { 684) -> Result<Option<Vec<lsp_types::TextEdit>>> {
686 let _p = profile("handle_formatting"); 685 let _p = profile::span("handle_formatting");
687 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 686 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
688 let file = snap.analysis.file_text(file_id)?; 687 let file = snap.analysis.file_text(file_id)?;
689 let crate_ids = snap.analysis.crate_for(file_id)?; 688 let crate_ids = snap.analysis.crate_for(file_id)?;
@@ -805,7 +804,7 @@ pub(crate) fn handle_code_action(
805 mut snap: GlobalStateSnapshot, 804 mut snap: GlobalStateSnapshot,
806 params: lsp_types::CodeActionParams, 805 params: lsp_types::CodeActionParams,
807) -> Result<Option<Vec<lsp_ext::CodeAction>>> { 806) -> Result<Option<Vec<lsp_ext::CodeAction>>> {
808 let _p = profile("handle_code_action"); 807 let _p = profile::span("handle_code_action");
809 // We intentionally don't support command-based actions, as those either 808 // We intentionally don't support command-based actions, as those either
810 // requires custom client-code anyway, or requires server-initiated edits. 809 // requires custom client-code anyway, or requires server-initiated edits.
811 // Server initiated edits break causality, so we avoid those as well. 810 // Server initiated edits break causality, so we avoid those as well.
@@ -847,7 +846,7 @@ pub(crate) fn handle_resolve_code_action(
847 mut snap: GlobalStateSnapshot, 846 mut snap: GlobalStateSnapshot,
848 params: lsp_ext::ResolveCodeActionParams, 847 params: lsp_ext::ResolveCodeActionParams,
849) -> Result<Option<lsp_ext::SnippetWorkspaceEdit>> { 848) -> Result<Option<lsp_ext::SnippetWorkspaceEdit>> {
850 let _p = profile("handle_resolve_code_action"); 849 let _p = profile::span("handle_resolve_code_action");
851 let file_id = from_proto::file_id(&snap, &params.code_action_params.text_document.uri)?; 850 let file_id = from_proto::file_id(&snap, &params.code_action_params.text_document.uri)?;
852 let line_index = snap.analysis.file_line_index(file_id)?; 851 let line_index = snap.analysis.file_line_index(file_id)?;
853 let range = from_proto::text_range(&line_index, params.code_action_params.range); 852 let range = from_proto::text_range(&line_index, params.code_action_params.range);
@@ -871,7 +870,7 @@ pub(crate) fn handle_code_lens(
871 snap: GlobalStateSnapshot, 870 snap: GlobalStateSnapshot,
872 params: lsp_types::CodeLensParams, 871 params: lsp_types::CodeLensParams,
873) -> Result<Option<Vec<CodeLens>>> { 872) -> Result<Option<Vec<CodeLens>>> {
874 let _p = profile("handle_code_lens"); 873 let _p = profile::span("handle_code_lens");
875 let mut lenses: Vec<CodeLens> = Default::default(); 874 let mut lenses: Vec<CodeLens> = Default::default();
876 875
877 if snap.config.lens.none() { 876 if snap.config.lens.none() {
@@ -957,7 +956,7 @@ pub(crate) fn handle_code_lens_resolve(
957 snap: GlobalStateSnapshot, 956 snap: GlobalStateSnapshot,
958 code_lens: CodeLens, 957 code_lens: CodeLens,
959) -> Result<CodeLens> { 958) -> Result<CodeLens> {
960 let _p = profile("handle_code_lens_resolve"); 959 let _p = profile::span("handle_code_lens_resolve");
961 let data = code_lens.data.unwrap(); 960 let data = code_lens.data.unwrap();
962 let resolve = from_json::<Option<CodeLensResolveData>>("CodeLensResolveData", data)?; 961 let resolve = from_json::<Option<CodeLensResolveData>>("CodeLensResolveData", data)?;
963 match resolve { 962 match resolve {
@@ -994,7 +993,7 @@ pub(crate) fn handle_document_highlight(
994 snap: GlobalStateSnapshot, 993 snap: GlobalStateSnapshot,
995 params: lsp_types::DocumentHighlightParams, 994 params: lsp_types::DocumentHighlightParams,
996) -> Result<Option<Vec<DocumentHighlight>>> { 995) -> Result<Option<Vec<DocumentHighlight>>> {
997 let _p = profile("handle_document_highlight"); 996 let _p = profile::span("handle_document_highlight");
998 let position = from_proto::file_position(&snap, params.text_document_position_params)?; 997 let position = from_proto::file_position(&snap, params.text_document_position_params)?;
999 let line_index = snap.analysis.file_line_index(position.file_id)?; 998 let line_index = snap.analysis.file_line_index(position.file_id)?;
1000 999
@@ -1021,7 +1020,7 @@ pub(crate) fn handle_ssr(
1021 snap: GlobalStateSnapshot, 1020 snap: GlobalStateSnapshot,
1022 params: lsp_ext::SsrParams, 1021 params: lsp_ext::SsrParams,
1023) -> Result<lsp_types::WorkspaceEdit> { 1022) -> Result<lsp_types::WorkspaceEdit> {
1024 let _p = profile("handle_ssr"); 1023 let _p = profile::span("handle_ssr");
1025 let selections = params 1024 let selections = params
1026 .selections 1025 .selections
1027 .iter() 1026 .iter()
@@ -1041,7 +1040,7 @@ pub(crate) fn publish_diagnostics(
1041 snap: &GlobalStateSnapshot, 1040 snap: &GlobalStateSnapshot,
1042 file_id: FileId, 1041 file_id: FileId,
1043) -> Result<Vec<Diagnostic>> { 1042) -> Result<Vec<Diagnostic>> {
1044 let _p = profile("publish_diagnostics"); 1043 let _p = profile::span("publish_diagnostics");
1045 let line_index = snap.analysis.file_line_index(file_id)?; 1044 let line_index = snap.analysis.file_line_index(file_id)?;
1046 let diagnostics: Vec<Diagnostic> = snap 1045 let diagnostics: Vec<Diagnostic> = snap
1047 .analysis 1046 .analysis
@@ -1064,7 +1063,7 @@ pub(crate) fn handle_inlay_hints(
1064 snap: GlobalStateSnapshot, 1063 snap: GlobalStateSnapshot,
1065 params: InlayHintsParams, 1064 params: InlayHintsParams,
1066) -> Result<Vec<InlayHint>> { 1065) -> Result<Vec<InlayHint>> {
1067 let _p = profile("handle_inlay_hints"); 1066 let _p = profile::span("handle_inlay_hints");
1068 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 1067 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
1069 let line_index = snap.analysis.file_line_index(file_id)?; 1068 let line_index = snap.analysis.file_line_index(file_id)?;
1070 Ok(snap 1069 Ok(snap
@@ -1079,7 +1078,7 @@ pub(crate) fn handle_call_hierarchy_prepare(
1079 snap: GlobalStateSnapshot, 1078 snap: GlobalStateSnapshot,
1080 params: CallHierarchyPrepareParams, 1079 params: CallHierarchyPrepareParams,
1081) -> Result<Option<Vec<CallHierarchyItem>>> { 1080) -> Result<Option<Vec<CallHierarchyItem>>> {
1082 let _p = profile("handle_call_hierarchy_prepare"); 1081 let _p = profile::span("handle_call_hierarchy_prepare");
1083 let position = from_proto::file_position(&snap, params.text_document_position_params)?; 1082 let position = from_proto::file_position(&snap, params.text_document_position_params)?;
1084 1083
1085 let nav_info = match snap.analysis.call_hierarchy(position)? { 1084 let nav_info = match snap.analysis.call_hierarchy(position)? {
@@ -1101,7 +1100,7 @@ pub(crate) fn handle_call_hierarchy_incoming(
1101 snap: GlobalStateSnapshot, 1100 snap: GlobalStateSnapshot,
1102 params: CallHierarchyIncomingCallsParams, 1101 params: CallHierarchyIncomingCallsParams,
1103) -> Result<Option<Vec<CallHierarchyIncomingCall>>> { 1102) -> Result<Option<Vec<CallHierarchyIncomingCall>>> {
1104 let _p = profile("handle_call_hierarchy_incoming"); 1103 let _p = profile::span("handle_call_hierarchy_incoming");
1105 let item = params.item; 1104 let item = params.item;
1106 1105
1107 let doc = TextDocumentIdentifier::new(item.uri); 1106 let doc = TextDocumentIdentifier::new(item.uri);
@@ -1136,7 +1135,7 @@ pub(crate) fn handle_call_hierarchy_outgoing(
1136 snap: GlobalStateSnapshot, 1135 snap: GlobalStateSnapshot,
1137 params: CallHierarchyOutgoingCallsParams, 1136 params: CallHierarchyOutgoingCallsParams,
1138) -> Result<Option<Vec<CallHierarchyOutgoingCall>>> { 1137) -> Result<Option<Vec<CallHierarchyOutgoingCall>>> {
1139 let _p = profile("handle_call_hierarchy_outgoing"); 1138 let _p = profile::span("handle_call_hierarchy_outgoing");
1140 let item = params.item; 1139 let item = params.item;
1141 1140
1142 let doc = TextDocumentIdentifier::new(item.uri); 1141 let doc = TextDocumentIdentifier::new(item.uri);
@@ -1171,7 +1170,7 @@ pub(crate) fn handle_semantic_tokens(
1171 snap: GlobalStateSnapshot, 1170 snap: GlobalStateSnapshot,
1172 params: SemanticTokensParams, 1171 params: SemanticTokensParams,
1173) -> Result<Option<SemanticTokensResult>> { 1172) -> Result<Option<SemanticTokensResult>> {
1174 let _p = profile("handle_semantic_tokens"); 1173 let _p = profile::span("handle_semantic_tokens");
1175 1174
1176 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 1175 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
1177 let text = snap.analysis.file_text(file_id)?; 1176 let text = snap.analysis.file_text(file_id)?;
@@ -1190,7 +1189,7 @@ pub(crate) fn handle_semantic_tokens_edits(
1190 snap: GlobalStateSnapshot, 1189 snap: GlobalStateSnapshot,
1191 params: SemanticTokensEditsParams, 1190 params: SemanticTokensEditsParams,
1192) -> Result<Option<SemanticTokensEditResult>> { 1191) -> Result<Option<SemanticTokensEditResult>> {
1193 let _p = profile("handle_semantic_tokens_edits"); 1192 let _p = profile::span("handle_semantic_tokens_edits");
1194 1193
1195 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?; 1194 let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
1196 let text = snap.analysis.file_text(file_id)?; 1195 let text = snap.analysis.file_text(file_id)?;
@@ -1220,7 +1219,7 @@ pub(crate) fn handle_semantic_tokens_range(
1220 snap: GlobalStateSnapshot, 1219 snap: GlobalStateSnapshot,
1221 params: SemanticTokensRangeParams, 1220 params: SemanticTokensRangeParams,
1222) -> Result<Option<SemanticTokensRangeResult>> { 1221) -> Result<Option<SemanticTokensRangeResult>> {
1223 let _p = profile("handle_semantic_tokens_range"); 1222 let _p = profile::span("handle_semantic_tokens_range");
1224 1223
1225 let frange = from_proto::file_range(&snap, params.text_document, params.range)?; 1224 let frange = from_proto::file_range(&snap, params.text_document, params.range)?;
1226 let text = snap.analysis.file_text(frange.file_id)?; 1225 let text = snap.analysis.file_text(frange.file_id)?;
diff --git a/crates/rust-analyzer/src/lib.rs b/crates/rust-analyzer/src/lib.rs
index ed37992cd..8d2e76cc2 100644
--- a/crates/rust-analyzer/src/lib.rs
+++ b/crates/rust-analyzer/src/lib.rs
@@ -74,16 +74,16 @@ impl std::error::Error for LspError {}
74fn print_memory_usage(mut host: AnalysisHost, vfs: Vfs) { 74fn print_memory_usage(mut host: AnalysisHost, vfs: Vfs) {
75 let mut mem = host.per_query_memory_usage(); 75 let mut mem = host.per_query_memory_usage();
76 76
77 let before = ra_prof::memory_usage(); 77 let before = profile::memory_usage();
78 drop(vfs); 78 drop(vfs);
79 let vfs = before.allocated - ra_prof::memory_usage().allocated; 79 let vfs = before.allocated - profile::memory_usage().allocated;
80 mem.push(("VFS".into(), vfs)); 80 mem.push(("VFS".into(), vfs));
81 81
82 let before = ra_prof::memory_usage(); 82 let before = profile::memory_usage();
83 drop(host); 83 drop(host);
84 mem.push(("Unaccounted".into(), before.allocated - ra_prof::memory_usage().allocated)); 84 mem.push(("Unaccounted".into(), before.allocated - profile::memory_usage().allocated));
85 85
86 mem.push(("Remaining".into(), ra_prof::memory_usage().allocated)); 86 mem.push(("Remaining".into(), profile::memory_usage().allocated));
87 87
88 for (name, bytes) in mem { 88 for (name, bytes) in mem {
89 eprintln!("{:>8} {}", bytes, name); 89 eprintln!("{:>8} {}", bytes, name);
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index e6cf46df2..32962b088 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -10,7 +10,6 @@ use lsp_server::{Connection, Notification, Request, Response};
10use lsp_types::notification::Notification as _; 10use lsp_types::notification::Notification as _;
11use ra_db::VfsPath; 11use ra_db::VfsPath;
12use ra_ide::{Canceled, FileId}; 12use ra_ide::{Canceled, FileId};
13use ra_prof::profile;
14 13
15use crate::{ 14use crate::{
16 config::Config, 15 config::Config,
@@ -173,7 +172,7 @@ impl GlobalState {
173 fn handle_event(&mut self, event: Event) -> Result<()> { 172 fn handle_event(&mut self, event: Event) -> Result<()> {
174 let loop_start = Instant::now(); 173 let loop_start = Instant::now();
175 // NOTE: don't count blocking select! call as a loop-turn time 174 // NOTE: don't count blocking select! call as a loop-turn time
176 let _p = profile("GlobalState::handle_event"); 175 let _p = profile::span("GlobalState::handle_event");
177 176
178 log::info!("handle_event({:?})", event); 177 log::info!("handle_event({:?})", event);
179 let queue_count = self.task_pool.handle.len(); 178 let queue_count = self.task_pool.handle.len();
@@ -204,7 +203,7 @@ impl GlobalState {
204 self.analysis_host.maybe_collect_garbage(); 203 self.analysis_host.maybe_collect_garbage();
205 } 204 }
206 Event::Vfs(mut task) => { 205 Event::Vfs(mut task) => {
207 let _p = profile("GlobalState::handle_event/vfs"); 206 let _p = profile::span("GlobalState::handle_event/vfs");
208 loop { 207 loop {
209 match task { 208 match task {
210 vfs::loader::Message::Loaded { files } => { 209 vfs::loader::Message::Loaded { files } => {
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 1907f2f13..f74f2c02c 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -4,7 +4,6 @@ use std::{mem, sync::Arc};
4use flycheck::FlycheckHandle; 4use flycheck::FlycheckHandle;
5use ra_db::{CrateGraph, SourceRoot, VfsPath}; 5use ra_db::{CrateGraph, SourceRoot, VfsPath};
6use ra_ide::AnalysisChange; 6use ra_ide::AnalysisChange;
7use ra_prof::profile;
8use ra_project_model::{ProcMacroClient, ProjectWorkspace}; 7use ra_project_model::{ProcMacroClient, ProjectWorkspace};
9use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind}; 8use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind};
10 9
@@ -17,7 +16,7 @@ use crate::{
17 16
18impl GlobalState { 17impl GlobalState {
19 pub(crate) fn update_configuration(&mut self, config: Config) { 18 pub(crate) fn update_configuration(&mut self, config: Config) {
20 let _p = profile("GlobalState::update_configuration"); 19 let _p = profile::span("GlobalState::update_configuration");
21 let old_config = mem::replace(&mut self.config, config); 20 let old_config = mem::replace(&mut self.config, config);
22 if self.config.lru_capacity != old_config.lru_capacity { 21 if self.config.lru_capacity != old_config.lru_capacity {
23 self.analysis_host.update_lru_capacity(old_config.lru_capacity); 22 self.analysis_host.update_lru_capacity(old_config.lru_capacity);
@@ -115,7 +114,7 @@ impl GlobalState {
115 }); 114 });
116 } 115 }
117 pub(crate) fn switch_workspaces(&mut self, workspaces: Vec<anyhow::Result<ProjectWorkspace>>) { 116 pub(crate) fn switch_workspaces(&mut self, workspaces: Vec<anyhow::Result<ProjectWorkspace>>) {
118 let _p = profile("GlobalState::switch_workspaces"); 117 let _p = profile::span("GlobalState::switch_workspaces");
119 log::info!("reloading projects: {:?}", self.config.linked_projects); 118 log::info!("reloading projects: {:?}", self.config.linked_projects);
120 119
121 let mut has_errors = false; 120 let mut has_errors = false;
@@ -300,7 +299,7 @@ pub(crate) struct SourceRootConfig {
300 299
301impl SourceRootConfig { 300impl SourceRootConfig {
302 pub(crate) fn partition(&self, vfs: &vfs::Vfs) -> Vec<SourceRoot> { 301 pub(crate) fn partition(&self, vfs: &vfs::Vfs) -> Vec<SourceRoot> {
303 let _p = profile("SourceRootConfig::partition"); 302 let _p = profile::span("SourceRootConfig::partition");
304 self.fsc 303 self.fsc
305 .partition(vfs) 304 .partition(vfs)
306 .into_iter() 305 .into_iter()
diff --git a/crates/rust-analyzer/tests/heavy_tests/support.rs b/crates/rust-analyzer/tests/heavy_tests/support.rs
index f242c8165..15866fbb1 100644
--- a/crates/rust-analyzer/tests/heavy_tests/support.rs
+++ b/crates/rust-analyzer/tests/heavy_tests/support.rs
@@ -62,7 +62,7 @@ impl<'a> Project<'a> {
62 static INIT: Once = Once::new(); 62 static INIT: Once = Once::new();
63 INIT.call_once(|| { 63 INIT.call_once(|| {
64 env_logger::builder().is_test(true).try_init().unwrap(); 64 env_logger::builder().is_test(true).try_init().unwrap();
65 ra_prof::init_from(crate::PROFILE); 65 profile::init_from(crate::PROFILE);
66 }); 66 });
67 67
68 for entry in Fixture::parse(self.fixture) { 68 for entry in Fixture::parse(self.fixture) {
diff --git a/xtask/tests/tidy.rs b/xtask/tests/tidy.rs
index 4ff72865e..7384205db 100644
--- a/xtask/tests/tidy.rs
+++ b/xtask/tests/tidy.rs
@@ -197,7 +197,7 @@ impl TidyDocs {
197 "ra_ide", 197 "ra_ide",
198 "ra_mbe", 198 "ra_mbe",
199 "ra_parser", 199 "ra_parser",
200 "ra_prof", 200 "profile",
201 "ra_project_model", 201 "ra_project_model",
202 "ra_syntax", 202 "ra_syntax",
203 "ra_tt", 203 "ra_tt",