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:
bors[bot] 2021-03-02 05:20:32 +00:00 committed by GitHub
commit b7fa6dfabc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 9 deletions

View file

@ -68,7 +68,7 @@ impl BenchCmd {
load_out_dirs_from_check: self.load_output_dirs,
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, &|_| {})?;
eprintln!("{:?}\n", start.elapsed());

View file

@ -64,7 +64,7 @@ impl AnalysisStatsCmd {
load_out_dirs_from_check: self.load_output_dirs,
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, &|_| {})?;
let db = host.raw_database();
eprintln!("{:<20} {}", "Database loaded:", db_load_sw.elapsed());

View file

@ -35,7 +35,8 @@ pub fn diagnostics(
) -> Result<()> {
let cargo_config = Default::default();
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 analysis = host.analysis();

View file

@ -23,7 +23,7 @@ pub fn load_workspace_at(
cargo_config: &CargoConfig,
load_config: &LoadCargoConfig,
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 = ProjectManifest::discover_single(&root)?;
let workspace = ProjectWorkspace::load(root, cargo_config, progress)?;
@ -35,7 +35,7 @@ pub fn load_workspace(
ws: ProjectWorkspace,
config: &LoadCargoConfig,
progress: &dyn Fn(String),
) -> Result<(AnalysisHost, vfs::Vfs)> {
) -> Result<(AnalysisHost, vfs::Vfs, Option<ProcMacroClient>)> {
let (sender, receiver) = unbounded();
let mut vfs = vfs::Vfs::default();
let mut loader = {
@ -80,7 +80,7 @@ pub fn load_workspace(
log::debug!("crate graph: {:?}", crate_graph);
let host =
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(
@ -138,7 +138,8 @@ mod tests {
let cargo_config = Default::default();
let load_cargo_config =
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();
// RA has quite a few crates, but the exact count doesn't matter

View file

@ -11,7 +11,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
let cargo_config = Default::default();
let load_cargo_config =
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, &|_| {})?;
let db = host.raw_database();
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 load_cargo_config =
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, &|_| {})?;
let db = host.raw_database();
let mut match_finder = MatchFinder::at_first_file(db)?;