aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-02 05:20:32 +0000
committerGitHub <[email protected]>2021-03-02 05:20:32 +0000
commitb7fa6dfabc7a5326c78aa19807fd6c30ca5d1b4b (patch)
tree5dc212a8a36f32a5fddc56e868d7dbf4006bd04c
parent477c1ac105a3b2ed8aafc8c3b09da81984725461 (diff)
parent877521325f81eb5965848e9d24ccbf6d7db6d8e4 (diff)
Merge #7844
7844: Fix ProcMacroClient dropped too early in cli r=edwin0cheng a=edwin0cheng Fix #7843 bors r+ Co-authored-by: Edwin Cheng <[email protected]>
-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/cli/diagnostics.rs3
-rw-r--r--crates/rust-analyzer/src/cli/load_cargo.rs9
-rw-r--r--crates/rust-analyzer/src/cli/ssr.rs4
5 files changed, 11 insertions, 9 deletions
diff --git a/crates/rust-analyzer/src/cli/analysis_bench.rs b/crates/rust-analyzer/src/cli/analysis_bench.rs
index 8991f3bdb..ebbbf0596 100644
--- a/crates/rust-analyzer/src/cli/analysis_bench.rs
+++ b/crates/rust-analyzer/src/cli/analysis_bench.rs
@@ -68,7 +68,7 @@ impl BenchCmd {
68 load_out_dirs_from_check: self.load_output_dirs, 68 load_out_dirs_from_check: self.load_output_dirs,
69 with_proc_macro: self.with_proc_macro, 69 with_proc_macro: self.with_proc_macro,
70 }; 70 };
71 let (mut host, vfs) = 71 let (mut host, vfs, _proc_macro) =
72 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; 72 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
73 eprintln!("{:?}\n", start.elapsed()); 73 eprintln!("{:?}\n", start.elapsed());
74 74
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs
index 9072d8944..ad0759bda 100644
--- a/crates/rust-analyzer/src/cli/analysis_stats.rs
+++ b/crates/rust-analyzer/src/cli/analysis_stats.rs
@@ -64,7 +64,7 @@ impl AnalysisStatsCmd {
64 load_out_dirs_from_check: self.load_output_dirs, 64 load_out_dirs_from_check: self.load_output_dirs,
65 with_proc_macro: self.with_proc_macro, 65 with_proc_macro: self.with_proc_macro,
66 }; 66 };
67 let (host, vfs) = 67 let (host, vfs, _proc_macro) =
68 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?; 68 load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
69 let db = host.raw_database(); 69 let db = host.raw_database();
70 eprintln!("{:<20} {}", "Database loaded:", db_load_sw.elapsed()); 70 eprintln!("{:<20} {}", "Database loaded:", db_load_sw.elapsed());
diff --git a/crates/rust-analyzer/src/cli/diagnostics.rs b/crates/rust-analyzer/src/cli/diagnostics.rs
index 876f6c44f..8b985716b 100644
--- a/crates/rust-analyzer/src/cli/diagnostics.rs
+++ b/crates/rust-analyzer/src/cli/diagnostics.rs
@@ -35,7 +35,8 @@ pub fn diagnostics(
35) -> Result<()> { 35) -> Result<()> {
36 let cargo_config = Default::default(); 36 let cargo_config = Default::default();
37 let load_cargo_config = LoadCargoConfig { load_out_dirs_from_check, with_proc_macro }; 37 let load_cargo_config = LoadCargoConfig { load_out_dirs_from_check, with_proc_macro };
38 let (host, _vfs) = load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?; 38 let (host, _vfs, _proc_macro) =
39 load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
39 let db = host.raw_database(); 40 let db = host.raw_database();
40 let analysis = host.analysis(); 41 let analysis = host.analysis();
41 42
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs
index 23442afac..310c36904 100644
--- a/crates/rust-analyzer/src/cli/load_cargo.rs
+++ b/crates/rust-analyzer/src/cli/load_cargo.rs
@@ -23,7 +23,7 @@ pub fn load_workspace_at(
23 cargo_config: &CargoConfig, 23 cargo_config: &CargoConfig,
24 load_config: &LoadCargoConfig, 24 load_config: &LoadCargoConfig,
25 progress: &dyn Fn(String), 25 progress: &dyn Fn(String),
26) -> Result<(AnalysisHost, vfs::Vfs)> { 26) -> Result<(AnalysisHost, vfs::Vfs, Option<ProcMacroClient>)> {
27 let root = AbsPathBuf::assert(std::env::current_dir()?.join(root)); 27 let root = AbsPathBuf::assert(std::env::current_dir()?.join(root));
28 let root = ProjectManifest::discover_single(&root)?; 28 let root = ProjectManifest::discover_single(&root)?;
29 let workspace = ProjectWorkspace::load(root, cargo_config, progress)?; 29 let workspace = ProjectWorkspace::load(root, cargo_config, progress)?;
@@ -35,7 +35,7 @@ pub fn load_workspace(
35 ws: ProjectWorkspace, 35 ws: ProjectWorkspace,
36 config: &LoadCargoConfig, 36 config: &LoadCargoConfig,
37 progress: &dyn Fn(String), 37 progress: &dyn Fn(String),
38) -> Result<(AnalysisHost, vfs::Vfs)> { 38) -> Result<(AnalysisHost, vfs::Vfs, Option<ProcMacroClient>)> {
39 let (sender, receiver) = unbounded(); 39 let (sender, receiver) = unbounded();
40 let mut vfs = vfs::Vfs::default(); 40 let mut vfs = vfs::Vfs::default();
41 let mut loader = { 41 let mut loader = {
@@ -80,7 +80,7 @@ pub fn load_workspace(
80 log::debug!("crate graph: {:?}", crate_graph); 80 log::debug!("crate graph: {:?}", crate_graph);
81 let host = 81 let host =
82 load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver); 82 load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver);
83 Ok((host, vfs)) 83 Ok((host, vfs, proc_macro_client))
84} 84}
85 85
86fn load_crate_graph( 86fn load_crate_graph(
@@ -138,7 +138,8 @@ mod tests {
138 let cargo_config = Default::default(); 138 let cargo_config = Default::default();
139 let load_cargo_config = 139 let load_cargo_config =
140 LoadCargoConfig { load_out_dirs_from_check: false, with_proc_macro: false }; 140 LoadCargoConfig { load_out_dirs_from_check: false, with_proc_macro: false };
141 let (host, _vfs) = load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?; 141 let (host, _vfs, _proc_macro) =
142 load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
142 143
143 let n_crates = Crate::all(host.raw_database()).len(); 144 let n_crates = Crate::all(host.raw_database()).len();
144 // RA has quite a few crates, but the exact count doesn't matter 145 // RA has quite a few crates, but the exact count doesn't matter
diff --git a/crates/rust-analyzer/src/cli/ssr.rs b/crates/rust-analyzer/src/cli/ssr.rs
index 71a8f8fb9..79f426fff 100644
--- a/crates/rust-analyzer/src/cli/ssr.rs
+++ b/crates/rust-analyzer/src/cli/ssr.rs
@@ -11,7 +11,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
11 let cargo_config = Default::default(); 11 let cargo_config = Default::default();
12 let load_cargo_config = 12 let load_cargo_config =
13 LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true }; 13 LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
14 let (host, vfs) = 14 let (host, vfs, _proc_macro) =
15 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?; 15 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
16 let db = host.raw_database(); 16 let db = host.raw_database();
17 let mut match_finder = MatchFinder::at_first_file(db)?; 17 let mut match_finder = MatchFinder::at_first_file(db)?;
@@ -38,7 +38,7 @@ pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<Stri
38 let cargo_config = Default::default(); 38 let cargo_config = Default::default();
39 let load_cargo_config = 39 let load_cargo_config =
40 LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true }; 40 LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
41 let (host, _vfs) = 41 let (host, _vfs, _proc_macro) =
42 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?; 42 load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
43 let db = host.raw_database(); 43 let db = host.raw_database();
44 let mut match_finder = MatchFinder::at_first_file(db)?; 44 let mut match_finder = MatchFinder::at_first_file(db)?;