mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
Pop up a notification for the MSRV project loading warning
This commit is contained in:
parent
0424e2e2bf
commit
1427a91c62
2 changed files with 29 additions and 16 deletions
|
|
@ -637,6 +637,25 @@ impl GlobalState {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn check_workspaces_msrv(&self) -> impl Iterator<Item = String> + '_ {
|
||||
self.workspaces.iter().filter_map(|ws| {
|
||||
if let Some(toolchain) = &ws.toolchain {
|
||||
if *toolchain < crate::MINIMUM_SUPPORTED_TOOLCHAIN_VERSION {
|
||||
return Some(format!(
|
||||
"Workspace `{}` is using an outdated toolchain version `{}` but \
|
||||
rust-analyzer only supports `{}` and higher.\n\
|
||||
Consider using the rust-analyzer rustup component for your toolchain or
|
||||
upgrade your toolchain to a supported version.\n\n",
|
||||
ws.manifest_or_root(),
|
||||
toolchain,
|
||||
crate::MINIMUM_SUPPORTED_TOOLCHAIN_VERSION,
|
||||
));
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for GlobalState {
|
||||
|
|
|
|||
|
|
@ -178,26 +178,15 @@ impl GlobalState {
|
|||
}
|
||||
|
||||
if !self.workspaces.is_empty() {
|
||||
self.check_workspaces_msrv().for_each(|e| {
|
||||
status.health |= lsp_ext::Health::Warning;
|
||||
format_to!(message, "{e}");
|
||||
});
|
||||
|
||||
let proc_macro_clients =
|
||||
self.proc_macro_clients.iter().map(Some).chain(iter::repeat_with(|| None));
|
||||
|
||||
for (ws, proc_macro_client) in self.workspaces.iter().zip(proc_macro_clients) {
|
||||
if let Some(toolchain) = &ws.toolchain {
|
||||
if *toolchain < crate::MINIMUM_SUPPORTED_TOOLCHAIN_VERSION {
|
||||
status.health |= lsp_ext::Health::Warning;
|
||||
format_to!(
|
||||
message,
|
||||
"Workspace `{}` is using an outdated toolchain version `{}` but \
|
||||
rust-analyzer only supports `{}` and higher.\n\
|
||||
Consider using the rust-analyzer rustup component for your toolchain or
|
||||
upgrade your toolchain to a supported version.\n\n",
|
||||
ws.manifest_or_root(),
|
||||
toolchain,
|
||||
crate::MINIMUM_SUPPORTED_TOOLCHAIN_VERSION,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let ProjectWorkspaceKind::Cargo { error: Some(error), .. }
|
||||
| ProjectWorkspaceKind::DetachedFile {
|
||||
cargo: Some((_, _, Some(error))), ..
|
||||
|
|
@ -529,6 +518,11 @@ impl GlobalState {
|
|||
// we don't care about build-script results, they are stale.
|
||||
// FIXME: can we abort the build scripts here if they are already running?
|
||||
self.workspaces = Arc::new(workspaces);
|
||||
self.check_workspaces_msrv().for_each(|message| {
|
||||
self.send_notification::<lsp_types::notification::ShowMessage>(
|
||||
lsp_types::ShowMessageParams { typ: lsp_types::MessageType::WARNING, message },
|
||||
);
|
||||
});
|
||||
|
||||
if self.config.run_build_scripts(None) {
|
||||
self.build_deps_changed = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue