mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Merge #7844
7844: Fix ProcMacroClient dropped too early in cli r=edwin0cheng a=edwin0cheng Fix #7843 bors r+ Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
This commit is contained in:
commit
b7fa6dfabc
5 changed files with 11 additions and 9 deletions
|
@ -68,7 +68,7 @@ impl BenchCmd {
|
||||||
load_out_dirs_from_check: self.load_output_dirs,
|
load_out_dirs_from_check: self.load_output_dirs,
|
||||||
with_proc_macro: self.with_proc_macro,
|
with_proc_macro: self.with_proc_macro,
|
||||||
};
|
};
|
||||||
let (mut host, vfs) =
|
let (mut host, vfs, _proc_macro) =
|
||||||
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
eprintln!("{:?}\n", start.elapsed());
|
eprintln!("{:?}\n", start.elapsed());
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ impl AnalysisStatsCmd {
|
||||||
load_out_dirs_from_check: self.load_output_dirs,
|
load_out_dirs_from_check: self.load_output_dirs,
|
||||||
with_proc_macro: self.with_proc_macro,
|
with_proc_macro: self.with_proc_macro,
|
||||||
};
|
};
|
||||||
let (host, vfs) =
|
let (host, vfs, _proc_macro) =
|
||||||
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&self.path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
eprintln!("{:<20} {}", "Database loaded:", db_load_sw.elapsed());
|
eprintln!("{:<20} {}", "Database loaded:", db_load_sw.elapsed());
|
||||||
|
|
|
@ -35,7 +35,8 @@ pub fn diagnostics(
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config = LoadCargoConfig { load_out_dirs_from_check, with_proc_macro };
|
let load_cargo_config = LoadCargoConfig { load_out_dirs_from_check, with_proc_macro };
|
||||||
let (host, _vfs) = load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
let (host, _vfs, _proc_macro) =
|
||||||
|
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
let analysis = host.analysis();
|
let analysis = host.analysis();
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn load_workspace_at(
|
||||||
cargo_config: &CargoConfig,
|
cargo_config: &CargoConfig,
|
||||||
load_config: &LoadCargoConfig,
|
load_config: &LoadCargoConfig,
|
||||||
progress: &dyn Fn(String),
|
progress: &dyn Fn(String),
|
||||||
) -> Result<(AnalysisHost, vfs::Vfs)> {
|
) -> Result<(AnalysisHost, vfs::Vfs, Option<ProcMacroClient>)> {
|
||||||
let root = AbsPathBuf::assert(std::env::current_dir()?.join(root));
|
let root = AbsPathBuf::assert(std::env::current_dir()?.join(root));
|
||||||
let root = ProjectManifest::discover_single(&root)?;
|
let root = ProjectManifest::discover_single(&root)?;
|
||||||
let workspace = ProjectWorkspace::load(root, cargo_config, progress)?;
|
let workspace = ProjectWorkspace::load(root, cargo_config, progress)?;
|
||||||
|
@ -35,7 +35,7 @@ pub fn load_workspace(
|
||||||
ws: ProjectWorkspace,
|
ws: ProjectWorkspace,
|
||||||
config: &LoadCargoConfig,
|
config: &LoadCargoConfig,
|
||||||
progress: &dyn Fn(String),
|
progress: &dyn Fn(String),
|
||||||
) -> Result<(AnalysisHost, vfs::Vfs)> {
|
) -> Result<(AnalysisHost, vfs::Vfs, Option<ProcMacroClient>)> {
|
||||||
let (sender, receiver) = unbounded();
|
let (sender, receiver) = unbounded();
|
||||||
let mut vfs = vfs::Vfs::default();
|
let mut vfs = vfs::Vfs::default();
|
||||||
let mut loader = {
|
let mut loader = {
|
||||||
|
@ -80,7 +80,7 @@ pub fn load_workspace(
|
||||||
log::debug!("crate graph: {:?}", crate_graph);
|
log::debug!("crate graph: {:?}", crate_graph);
|
||||||
let host =
|
let host =
|
||||||
load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver);
|
load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver);
|
||||||
Ok((host, vfs))
|
Ok((host, vfs, proc_macro_client))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_crate_graph(
|
fn load_crate_graph(
|
||||||
|
@ -138,7 +138,8 @@ mod tests {
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config =
|
let load_cargo_config =
|
||||||
LoadCargoConfig { load_out_dirs_from_check: false, with_proc_macro: false };
|
LoadCargoConfig { load_out_dirs_from_check: false, with_proc_macro: false };
|
||||||
let (host, _vfs) = load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
let (host, _vfs, _proc_macro) =
|
||||||
|
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
|
|
||||||
let n_crates = Crate::all(host.raw_database()).len();
|
let n_crates = Crate::all(host.raw_database()).len();
|
||||||
// RA has quite a few crates, but the exact count doesn't matter
|
// RA has quite a few crates, but the exact count doesn't matter
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config =
|
let load_cargo_config =
|
||||||
LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
|
LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
|
||||||
let (host, vfs) =
|
let (host, vfs, _proc_macro) =
|
||||||
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
let mut match_finder = MatchFinder::at_first_file(db)?;
|
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
|
||||||
let cargo_config = Default::default();
|
let cargo_config = Default::default();
|
||||||
let load_cargo_config =
|
let load_cargo_config =
|
||||||
LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
|
LoadCargoConfig { load_out_dirs_from_check: true, with_proc_macro: true };
|
||||||
let (host, _vfs) =
|
let (host, _vfs, _proc_macro) =
|
||||||
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
load_workspace_at(&std::env::current_dir()?, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||||
let db = host.raw_database();
|
let db = host.raw_database();
|
||||||
let mut match_finder = MatchFinder::at_first_file(db)?;
|
let mut match_finder = MatchFinder::at_first_file(db)?;
|
||||||
|
|
Loading…
Reference in a new issue