Better error messages when the proc-macro-server fails to start
This commit is contained in:
parent
aeb07745d5
commit
50b27e57ba
@ -60,9 +60,9 @@ pub fn load_workspace(
|
||||
|
||||
let proc_macro_client = if load_config.with_proc_macro {
|
||||
let path = AbsPathBuf::assert(std::env::current_exe()?);
|
||||
Some(ProcMacroServer::spawn(path, &["proc-macro"]).unwrap())
|
||||
Ok(ProcMacroServer::spawn(path, &["proc-macro"]).unwrap())
|
||||
} else {
|
||||
None
|
||||
Err("proc macro server not started".to_owned())
|
||||
};
|
||||
|
||||
let crate_graph = ws.to_crate_graph(
|
||||
@ -89,7 +89,7 @@ pub fn load_workspace(
|
||||
if load_config.prefill_caches {
|
||||
host.analysis().parallel_prime_caches(1, |_| {})?;
|
||||
}
|
||||
Ok((host, vfs, proc_macro_client))
|
||||
Ok((host, vfs, proc_macro_client.ok()))
|
||||
}
|
||||
|
||||
fn load_crate_graph(
|
||||
|
@ -61,7 +61,7 @@ pub(crate) struct GlobalState {
|
||||
pub(crate) proc_macro_changed: bool,
|
||||
pub(crate) last_reported_status: Option<lsp_ext::ServerStatusParams>,
|
||||
pub(crate) source_root_config: SourceRootConfig,
|
||||
pub(crate) proc_macro_clients: Vec<Option<ProcMacroServer>>,
|
||||
pub(crate) proc_macro_clients: Vec<Result<ProcMacroServer, String>>,
|
||||
|
||||
pub(crate) flycheck: Vec<FlycheckHandle>,
|
||||
pub(crate) flycheck_sender: Sender<flycheck::Message>,
|
||||
|
@ -306,16 +306,16 @@ fn eq_ignore_build_data<'a>(
|
||||
if self.proc_macro_clients.is_empty() {
|
||||
if let Some((path, args)) = self.config.proc_macro_srv() {
|
||||
self.proc_macro_clients = (0..self.workspaces.len())
|
||||
.map(|_| match ProcMacroServer::spawn(path.clone(), args.clone()) {
|
||||
Ok(it) => Some(it),
|
||||
Err(err) => {
|
||||
tracing::error!(
|
||||
.map(|_| {
|
||||
ProcMacroServer::spawn(path.clone(), args.clone()).map_err(|err| {
|
||||
let error = format!(
|
||||
"Failed to run proc_macro_srv from path {}, error: {:?}",
|
||||
path.display(),
|
||||
err
|
||||
);
|
||||
None
|
||||
}
|
||||
tracing::error!(error);
|
||||
error
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
@ -539,14 +539,14 @@ pub(crate) fn partition(&self, vfs: &vfs::Vfs) -> Vec<SourceRoot> {
|
||||
/// Load the proc-macros for the given lib path, replacing all expanders whose names are in `dummy_replace`
|
||||
/// with an identity dummy expander.
|
||||
pub(crate) fn load_proc_macro(
|
||||
server: Option<&ProcMacroServer>,
|
||||
server: Result<&ProcMacroServer, &String>,
|
||||
path: &AbsPath,
|
||||
dummy_replace: &[Box<str>],
|
||||
) -> ProcMacroLoadResult {
|
||||
let res: Result<Vec<_>, String> = (|| {
|
||||
let dylib = MacroDylib::new(path.to_path_buf())
|
||||
.map_err(|io| format!("Proc-macro dylib loading failed: {io}"))?;
|
||||
let server = server.ok_or_else(|| format!("Proc-macro server not started"))?;
|
||||
let server = server.map_err(ToOwned::to_owned)?;
|
||||
let vec = server.load_dylib(dylib).map_err(|e| format!("{e}"))?;
|
||||
if vec.is_empty() {
|
||||
return Err("proc macro library returned no proc macros".to_string());
|
||||
|
Loading…
Reference in New Issue
Block a user