mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Merge #10024
10024: fix: Fix reporting of build script errors r=matklad a=jonas-schievink r? `@matklad` (mostly to double-check that the redundant code I removed was, in fact, redundant) Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9864 Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10023 Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
commit
cbbb7f351f
2 changed files with 22 additions and 16 deletions
|
@ -42,7 +42,7 @@ pub(crate) struct BuildScriptOutput {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WorkspaceBuildScripts {
|
impl WorkspaceBuildScripts {
|
||||||
pub fn run(
|
pub(crate) fn run(
|
||||||
config: &CargoConfig,
|
config: &CargoConfig,
|
||||||
workspace: &CargoWorkspace,
|
workspace: &CargoWorkspace,
|
||||||
progress: &dyn Fn(String),
|
progress: &dyn Fn(String),
|
||||||
|
@ -196,6 +196,10 @@ impl WorkspaceBuildScripts {
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn error(&self) -> Option<&str> {
|
||||||
|
self.error.as_deref()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: File a better way to know if it is a dylib.
|
// FIXME: File a better way to know if it is a dylib.
|
||||||
|
|
|
@ -232,14 +232,6 @@ impl GlobalState {
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
for ws in workspaces.iter() {
|
for ws in workspaces.iter() {
|
||||||
res.push(ws.run_build_scripts(&config, &progress));
|
res.push(ws.run_build_scripts(&config, &progress));
|
||||||
let ws = match ws {
|
|
||||||
ProjectWorkspace::Cargo { cargo, .. } => cargo,
|
|
||||||
ProjectWorkspace::DetachedFiles { .. } | ProjectWorkspace::Json { .. } => {
|
|
||||||
res.push(Ok(WorkspaceBuildScripts::default()));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
res.push(WorkspaceBuildScripts::run(&config, ws, &progress))
|
|
||||||
}
|
}
|
||||||
sender.send(Task::FetchBuildData(BuildDataProgress::End((workspaces, res)))).unwrap();
|
sender.send(Task::FetchBuildData(BuildDataProgress::End((workspaces, res)))).unwrap();
|
||||||
});
|
});
|
||||||
|
@ -453,19 +445,29 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_build_data_error(&self) -> Option<String> {
|
fn fetch_build_data_error(&self) -> Option<String> {
|
||||||
let mut buf = String::new();
|
let mut buf = "rust-analyzer failed to run build scripts:\n".to_string();
|
||||||
|
let mut has_errors = false;
|
||||||
|
|
||||||
for ws in &self.fetch_build_data_queue.last_op_result().1 {
|
for ws in &self.fetch_build_data_queue.last_op_result().1 {
|
||||||
if let Err(err) = ws {
|
match ws {
|
||||||
stdx::format_to!(buf, "rust-analyzer failed to run custom build: {:#}\n", err);
|
Ok(data) => {
|
||||||
|
if let Some(err) = data.error() {
|
||||||
|
has_errors = true;
|
||||||
|
stdx::format_to!(buf, "{:#}\n", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
has_errors = true;
|
||||||
|
stdx::format_to!(buf, "{:#}\n", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if buf.is_empty() {
|
if has_errors {
|
||||||
return None;
|
Some(buf)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(buf)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reload_flycheck(&mut self) {
|
fn reload_flycheck(&mut self) {
|
||||||
|
|
Loading…
Reference in a new issue