mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-29 10:58:02 +00:00
internal: fix salsa-ified crate graph working with lazy project discovery
This commit is contained in:
parent
2261e4e892
commit
9aa99eec60
2 changed files with 23 additions and 31 deletions
|
|
@ -208,7 +208,8 @@ impl ExpandErrorKind {
|
||||||
},
|
},
|
||||||
None => RenderedExpandError {
|
None => RenderedExpandError {
|
||||||
message: format!(
|
message: format!(
|
||||||
"internal error: proc-macro map is missing error entry for crate {def_crate:?}"
|
"internal error: proc-macro map is missing error entry for crate {:?}",
|
||||||
|
def_crate
|
||||||
),
|
),
|
||||||
error: true,
|
error: true,
|
||||||
kind: RenderedExpandError::GENERAL_KIND,
|
kind: RenderedExpandError::GENERAL_KIND,
|
||||||
|
|
|
||||||
|
|
@ -413,35 +413,26 @@ impl GlobalState {
|
||||||
.map(|res| res.as_ref().map_err(|e| e.to_string()))
|
.map(|res| res.as_ref().map_err(|e| e.to_string()))
|
||||||
.chain(iter::repeat_with(|| Err("proc-macro-srv is not running".into())));
|
.chain(iter::repeat_with(|| Err("proc-macro-srv is not running".into())));
|
||||||
for (client, paths) in proc_macro_clients.zip(paths) {
|
for (client, paths) in proc_macro_clients.zip(paths) {
|
||||||
paths
|
for (crate_id, res) in paths.iter() {
|
||||||
.into_iter()
|
let expansion_res = match client {
|
||||||
.map(move |(crate_id, res)| {
|
Ok(client) => match res {
|
||||||
(
|
Ok((crate_name, path)) => {
|
||||||
crate_id,
|
progress(path.to_string());
|
||||||
res.map_or_else(
|
let ignored_proc_macros = ignored_proc_macros
|
||||||
|e| Err((e, true)),
|
.iter()
|
||||||
|(crate_name, path)| {
|
.find_map(|(name, macros)| {
|
||||||
progress(path.to_string());
|
eq_ignore_underscore(name, crate_name).then_some(&**macros)
|
||||||
client.as_ref().map_err(|it| (it.clone(), true)).and_then(
|
})
|
||||||
|client| {
|
.unwrap_or_default();
|
||||||
load_proc_macro(
|
|
||||||
client,
|
load_proc_macro(client, path, ignored_proc_macros)
|
||||||
&path,
|
}
|
||||||
ignored_proc_macros
|
Err(e) => Err((e.clone(), true)),
|
||||||
.iter()
|
},
|
||||||
.find_map(|(name, macros)| {
|
Err(ref e) => Err((e.clone(), true)),
|
||||||
eq_ignore_underscore(name, &crate_name)
|
};
|
||||||
.then_some(&**macros)
|
builder.insert(*crate_id, expansion_res)
|
||||||
})
|
}
|
||||||
.unwrap_or_default(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.for_each(|(krate, res)| builder.insert(krate, res));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
change.set_proc_macros(builder);
|
change.set_proc_macros(builder);
|
||||||
|
|
@ -645,7 +636,7 @@ impl GlobalState {
|
||||||
Config::user_config_dir_path().as_deref(),
|
Config::user_config_dir_path().as_deref(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (self.proc_macro_clients.is_empty() || !same_workspaces)
|
if (self.proc_macro_clients.len() < self.workspaces.len() || !same_workspaces)
|
||||||
&& self.config.expand_proc_macros()
|
&& self.config.expand_proc_macros()
|
||||||
{
|
{
|
||||||
info!("Spawning proc-macro servers");
|
info!("Spawning proc-macro servers");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue